0

I have a small php website that sends a text message to any given number in US. I tried sending my self a text using it but didn't receive it. I sent it to my cousin's number and he received it. I am using Simple Mobile as my carrier and my cousin uses T-mobile. Could it be that somehow this message is being converted to short message? If so, is there any way I can fix it ? Because in future, I will need to send text messages to any given number and it would be nice if all intended recipients receive the texts without having to enable any thing.

Here is my code :

        require 'PHPMailer-master/PHPMailerAutoload.php';

        // Instantiate Class
        $mail = new PHPMailer();

        // Set up SMTP
        $mail->IsSMTP();                // Sets up a SMTP connection
        $mail->SMTPDebug  = 2;          // This will print debugging info
        $mail->SMTPAuth = true;         // Connection with the SMTP does require authorization
        $mail->SMTPSecure = "tls";      // Connect using a TLS connection
        $mail->Host = "smtp.gmail.com";
        $mail->Port = 587;
        $mail->Encoding = '7bit';       // SMS uses 7-bit encoding

        // Authentication
        $mail->Username   = "example@gmail.com"; // Login
        $mail->Password   = "password"; // Password

        // Compose
        $mail->Subject = "Testing";     // Subject (which isn't required)
        $mail->Body = "Testing";        // Body of our message

        // Send To
        $mail->AddAddress( "phoneNumber@tmomail.net" ); // Where to send it
        var_dump( $mail->send() );      // Send!
Student
  • 39
  • 5
  • Possible duplicate of [PHP mail form doesn't complete sending e-mail](https://stackoverflow.com/questions/24644436/php-mail-form-doesnt-complete-sending-e-mail) – M. Eriksson Aug 02 '17 at 22:06
  • 1
    if you want reliable SMS dont use a carriers own email gateway , use an SMS gateway –  Aug 02 '17 at 22:24
  • @rtfm Thanks! How can I do that ? Also, is there a free service for that ? – Student Aug 02 '17 at 22:38
  • @Student - Google is your friend. Search for "SMS gateway". I am not aware of any free ones though. – Alex Aug 03 '17 at 01:46
  • ok so I found out that since simple mobile runs on T-mobile's network, I had to use the T-mobile's domain name. But after sending few messages, it has stopped working altogether. The only thing that changed were the subject and message. – Student Aug 03 '17 at 04:26
  • Email to SMS is inconsistent and unreliable. Use a gateway with an HTTP API like Clickatell.com – Synchro Aug 03 '17 at 05:57

0 Answers0