I am trying to send out a text message to phone numbers. It works as long as it is under 11 digits, but if the phone number has 11 digits it fails. Is there a way to be flexible for both?
$phonenum = "16783293991"; //works if 6783293991
$from_name = "Gregory Smith";
$from_email = "[email protected]";
$from = sprintf ("From: %s <%s>\nSender: %s <%s>\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit\n", $from_name, $from_email, $from_name, $from_email);
$to = $phonenum;
$formatted_number = $to."@messaging.sprintpcs.com";
mail("$formatted_number", "", "$message", $from); //the empty field of "" is the subject line and is unnecessary
Check for
1
as the first digit, and verify length: