You would need an API to do this and the API should be provided by your SMS gateway or service provider.
To carry out your desired functions, then of course you might need a simple PHP script or an application that would handle it.
As others recommended, Twilio is a good option.