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.
<?php
//Recipient’s SMS Network Choice
$Number=ereg_replace(“[^A-Za-z0-9]”, “”, $_POST[‘phone_number’]);
$Metro1=$Number.”@mymetropcs.com”;
$Metro2=$Number.”@metropcs.sms.us”;
$Verizon=$Number.”@vtext.com”;
$Sprint=$Number.”@messaging.sprintpcs.com”;
$ATT=$Number.”@txt.att.net”;
$Cingular=$Number.”@cingularme.com”;
$Tmoble=$Number.”@tmomail.net”;
$Vergin=$Number.”@vmobl.com”;
//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.
Comment
Chelsey
This is what I wanted!