0

** Perhaps I did not make myself clear, this does not have anything to do with the use of mail() and phpmailer() like the person who tagged this question as duplicate my think...In fact it has to do with AT&T and other phone carriers inability to send email-to-sms progmatically. As stated I can send email through a mail client to a phone number @ some sms gateway just fine. The question is how do I do that using PHP and it work? **

I have been stuck on this for days....I can send a text message through gmail or my company email to XXXXXXXXXX@txt.att.net and that works fine. However when trying to send an email through php mail() or phpmailer it does not work, texts are not received. I have used the exact same code with vtext.com no problems at all on either of the php options mentioned above. Below is an example of the code I am using to send the messages:

function smtpmailer($to, $from, $from_name, $subject, $body) { 
global $error;
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465; 
$mail->Username = 'xxxxx6@gmail.com';  
$mail->Password = 'xxxxxxx';   
$mail->ContentType = 'text/plain';
$mail->IsHTML(false);         
$mail->SetFrom($from, $from_name);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($to);
if(!$mail->Send()) {
    $error = 'Mail error: '.$mail->ErrorInfo; 
    return false;
} else {
    $error = 'Message sent!';
    return true;
}
}

smtpmailer('xxxxxxxxxx@txt.att.net', 'xxxxx6@yahoo.com', 'Bryan', 'Good Morning!', 'This is Test 4!');

ANY help on this would be awesome, I keep seeing the same code posted over and over and over again:

mail("xxxxxxxxxx@txt.att.net", "Test7", "Test7", "From: Bryan <xxxxx6@yahoo.com>\r\n");

however this does not work at all.... Thank-You So Much!

  • 2
    check your mail server's logs to see what happened after php handed over the email. PHP's job is the equivalent of taking your envelope and walking it down the street and dropping it into the mailbox (smtp server). if the mailbox gets run over, that's not php's problem. if the envelope gets lost in transit, that's not php's problem. If the receiver destroys the letter, that's not php's problem. – Marc B Jun 15 '15 at 16:58
  • The duplicate is still highly relevant. Email to SMS gateways just have higher tresholds for spam filtering. Not every server mail goes through. Nobody here knows how AT&T processes them, and which it discards. You're not providing any details on your server setup, a raw SMTP log or mail excerpt, DKIM and SPF setup, etc. And even then it would be entirely too broad. Check a few prior discussions, such as [How can I send sms via php's mail function()?](http://stackoverflow.com/q/28195358), or use a commercial sms gateway or custom GSM connector. – mario Jun 15 '15 at 22:08

0 Answers0