Text messaging can be useful when you need to communicate time sensitive information to your customers. A lot of websites are now offering this over the traditional email communication. Sending a text message is just as easy as using PHP's mail function. All you need to know is two pieces of information: the phone number and the carrier's text message email domain. Needing to know the carrier is not the most ideal, but it is necessary. Luckily Kevin Jensen has compiled a list of carriers and domains, which can be found here.
Phone companies have internal lookups for different carriers but don't give access to developers. That is why we need to know the carrier. To send a text message you will need to use the following format:
[cc]{phoneNumber}@{carrierDomain}.[/cc]
PHP has the built-in function: mail().
Its prototype is:
[ccW lang="php"]bool mail (
string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]]
);[/ccW]
An example of how to use this function to send a text message is:
[ccW lang="php"]mail(
"5551234567@txt.att.net", "", "You have a new alert on our site!", "From: Your Name rn"
);[/ccW]
Who knew sending a text message with PHP was that easy? There are a few paid services out there that will allow you to hook into their API without knowing the carrier!