Valik Rudd

Freelance Web Designer & WordPress Specialist

Sending A Text (SMS) from PHP

Awesome find today! Ever have a need to send a text (SMS) message to a phone from a PHP application? Well, here is a way you can now do exactly that. I won’t try to make this a long post because there is nothing else I can say other than, here is the code.


//Recipient’s SMS Network Choice
$Number=ereg_replace(“[^A-Za-z0-9]“, “”, $_POST['phone_number']);

//Set up the message
$Message=”Here is a new message sent from PHP right to your phone!!”;
$headers = ‘From: This PHP App’ . “rn”;

//Now ready and send! (Use only the network that is applicable);
mail($Metro1, ‘Alert’, $Message,$headers);
mail($Metro2, ‘Alert’, $Message,$headers);
mail($Verizon, ‘Alert’, $Message,$headers);
mail($Sprint, ‘Alert’, $Message,$headers);
mail($ATT, ‘Alert’, $Message,$headers);
mail($Congular, ‘Alert’, $Message,$headers);
mail($Tmoble, ‘Alert’, $Message,$headers);
mail($Vergin, ‘Alert’, $Message,$headers);


Wasn’t that awesome… and super easy? I’ll be thinking of a way to use that in my next app.

I also just tried this, you should to. Send an email to one of the email addresses from above that applies to your mobile carrier. I did and it worked. Awesome way to send texts from email, if you know who their carrier is.

Posted in:
About the Author

Valik Rudd

Valik Rudd is a WordPress designer and has been in the web design industry for over 13 years. In the last 5 years he has been focusing more and more on WordPress and developing custom themes for individuals, businesses and corporations. His expertise in this technology allows him to write informative and useful articles and share them with the world.