phppup Posted January 11, 2019 Share Posted January 11, 2019 I have an old script for sending a text message to cellphone via PHP mail. The script has not changed in a year, and it did work approximately 9 months ago. Now, after dusting off the script and trying it, no message is received on the cellphone. When sent directly from my email account to 1231231234@mymetropcs.com, a text message arrives nearly immediately. But when sent through my email server script, even as a simplified test script <?php mail( '1231231234@mymetropcs.com', "How are you", "Your packaged has arrived!", "From: Me <MyEmail@yahoo.com>\r\n"); //OR even mail( '1231231234@mymetropcs.com', "", "Your packaged has arrived!", "From: Me <MyEmail@yahoo.com>\r\n"); ?> there is still nothing received on cellphone. How can I resolve this? Are there anti-spam filters generally in place and how can I overcome them? Is there a way to validate that the message I am sending is actually leaving the server? Or are there settings [there were none before and normal email messages are sent without any problems] that need to be adjusted to send a text message? Thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/308150-unable-to-send-text-to-metropcs-using-php-mail/ Share on other sites More sharing options...
requinix Posted January 11, 2019 Share Posted January 11, 2019 Don't claim to be someone you are not. If you want to attach your @yahoo.com email then you need to be sending this through your Yahoo mail account. As in configuring PHP and/or your server to send through it. Change the from to be something according to your domain name, see if that works. Quote Link to comment https://forums.phpfreaks.com/topic/308150-unable-to-send-text-to-metropcs-using-php-mail/#findComment-1563449 Share on other sites More sharing options...
phppup Posted January 11, 2019 Author Share Posted January 11, 2019 No change in functionality. ? Quote Link to comment https://forums.phpfreaks.com/topic/308150-unable-to-send-text-to-metropcs-using-php-mail/#findComment-1563450 Share on other sites More sharing options...
phppup Posted January 11, 2019 Author Share Posted January 11, 2019 Sent identical messages: one to email, another to cellphone. Only received the email. So I guess this proves (barring any code to provide support) that the email function is sending outbound messages. mail( '1231231234@mymetropcs.com', "How are you", "Your packaged has arrived!", "From: Me <MyOtherEmail@yahoo.com>\r\n"); mail( 'myemail@yahoo.com', "How are you", "Your packaged has arrived!", "From: Me <MyOtherEmail@yahoo.com>\r\n"); Are there any new issues with MetroPCS since they merged with T-Mobile in the USA? (MetroPCS personnel are essentially worthless in this matter.) Quote Link to comment https://forums.phpfreaks.com/topic/308150-unable-to-send-text-to-metropcs-using-php-mail/#findComment-1563453 Share on other sites More sharing options...
requinix Posted January 11, 2019 Share Posted January 11, 2019 According to your code you're still claiming to be sending from @yahoo.com. When I said not to do that, it wasn't a casual idea. Really. Don't do that. You could be getting caught in spam filters. Try using PHPMailer or Swift Mailer to send it. Quote Link to comment https://forums.phpfreaks.com/topic/308150-unable-to-send-text-to-metropcs-using-php-mail/#findComment-1563457 Share on other sites More sharing options...
phppup Posted January 11, 2019 Author Share Posted January 11, 2019 Sorry, but I did immediately make the change that you suggested. I just didn't convert it properly when cutting and pasting from the previous post. In fact, I agree with your appraisal and had experienced getting caught by those filters before. At this point I have used both my Yahoo addresses and my me@mydomainname.com and gotten similar results. The regular email (when not intercepted by spam filter) arrived in my inbox, but not a single text message has arrived on my phone via MetroPCS (except for an initial test sent directly from my Yahoo account, but not through PHP mail). Quote Link to comment https://forums.phpfreaks.com/topic/308150-unable-to-send-text-to-metropcs-using-php-mail/#findComment-1563459 Share on other sites More sharing options...
requinix Posted January 12, 2019 Share Posted January 12, 2019 That it worked from your Yahoo email but not PHP reinforces the idea that it's a spam thing. Try one of those mailers - they tend to construct more formal messages so they'll be a bit less likely to get caught by a filter. Quote Link to comment https://forums.phpfreaks.com/topic/308150-unable-to-send-text-to-metropcs-using-php-mail/#findComment-1563461 Share on other sites More sharing options...
phppup Posted January 12, 2019 Author Share Posted January 12, 2019 How would I be able to use one of those mailers? Quote Link to comment https://forums.phpfreaks.com/topic/308150-unable-to-send-text-to-metropcs-using-php-mail/#findComment-1563467 Share on other sites More sharing options...
requinix Posted January 12, 2019 Share Posted January 12, 2019 I suggest checking the documentation. Quote Link to comment https://forums.phpfreaks.com/topic/308150-unable-to-send-text-to-metropcs-using-php-mail/#findComment-1563468 Share on other sites More sharing options...
phppup Posted January 12, 2019 Author Share Posted January 12, 2019 So you're talking about setting up SMTP through Yahoo/Gmail etc.? Am I on the right path? Quote Link to comment https://forums.phpfreaks.com/topic/308150-unable-to-send-text-to-metropcs-using-php-mail/#findComment-1563472 Share on other sites More sharing options...
maxxd Posted January 12, 2019 Share Posted January 12, 2019 He's talking about using this or this, and checking the documentation about how to do so. Yes, you should be able to set up SMTP via Gmail on both. I've not used Yahoo or Swift, to be honest, but I use PHPMailer on a regular basis and can tell you it's simple and it works much better than PHP's native mail() function. Quote Link to comment https://forums.phpfreaks.com/topic/308150-unable-to-send-text-to-metropcs-using-php-mail/#findComment-1563479 Share on other sites More sharing options...
phppup Posted January 12, 2019 Author Share Posted January 12, 2019 I'll give it a try later on. Do emails sent this way display the Yahoo information, or are the headers modified. Thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/308150-unable-to-send-text-to-metropcs-using-php-mail/#findComment-1563482 Share on other sites More sharing options...
requinix Posted January 14, 2019 Share Posted January 14, 2019 ...Do text messages via emails show you the sender's address? I don't think I've ever received any. Quote Link to comment https://forums.phpfreaks.com/topic/308150-unable-to-send-text-to-metropcs-using-php-mail/#findComment-1563548 Share on other sites More sharing options...
phppup Posted January 14, 2019 Author Share Posted January 14, 2019 If I get it working again I'll let you know. I found this sample code that is SUPPOSED to work, but something is causing it to provide: Mailer Error: SMTP connect() failed. <?php $status = ""; $subject = "Sending Email Using PHP Mailer"; $body ='<p>Congratulations!</p>'; $body .='<p>You have successfully received an email from.</p>'; // Enter Your Email Address Here To Receive Email $email_to = "my_yahoo_email@yahoo.com"; $email_from = "myTESTemail@my_domain.com"; // Enter Sender Email $sender_name = "Mister Mail"; // Enter Sender Name require("PHPMailer/PHPMailerAutoload.php"); $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = "mail.my_domain.com"; // Enter Your Host/Server $mail->SMTPAuth = true; $mail->Username = "myTESTemail@my_domain.com"; // Enter Sender Email $mail->Password = "theTESTpassword"; //If SMTP requires TLS encryption then remove comment from it //$mail->SMTPSecure = "tls"; $mail->Port = 25; //tried 25 and 587 $mail->IsHTML(true); $mail->From = $email_from; $mail->FromName = $sender_name; $mail->Sender = $email_from; // indicates ReturnPath header $mail->AddReplyTo($email_from, "No Reply"); // indicates ReplyTo headers $mail->Subject = $subject; $mail->Body = $body; $mail->AddAddress($email_to); // If you know receiver name using following //$mail->AddAddress($email_to, "Recepient Name"); // To send CC remove comment from below //$mail->AddCC('username@email.com', "Recepient Name"); // To send attachment remove comment from below //$mail->AddAttachment('files/readme.txt'); /* Please note file must be available on your host to be attached with this email. */ if (!$mail->Send()){ $status = "Mailer Error: " . $mail->ErrorInfo; }else{ $status = "<div style='color:#FF0000; font-size:20px; font-weight:bold;'> An email has been sent to your email address.</div>"; } ?> <html> <head> <title>Send Email in PHP Using PHPMailer - AllPHPTricks.com</title> </head> <body> <?php echo $status; ?> <br /><br /> </body> </html> Not exactly sure if it's a C-Panel email issue, or the code, or just my lack of expertise. Any suggestions for finding a solution. Quote Link to comment https://forums.phpfreaks.com/topic/308150-unable-to-send-text-to-metropcs-using-php-mail/#findComment-1563556 Share on other sites More sharing options...
maxxd Posted January 15, 2019 Share Posted January 15, 2019 Add $mail->SMTPDebug = 2; before you try to send the mail. It'll give you a lot more detail as to the error that's happening. Quote Link to comment https://forums.phpfreaks.com/topic/308150-unable-to-send-text-to-metropcs-using-php-mail/#findComment-1563571 Share on other sites More sharing options...
phppup Posted January 16, 2019 Author Share Posted January 16, 2019 I thought it would get easier, but I was wrong. LOL Took maxxd advice and added to the top of my script, <?php $status = ""; $mail->SMTPDebug = 2; $subject = "Sending Email Using PHP Mailer"; but I didn't see any change in the Error Message which simply states: Mailer Error: SMTP connect() failed In other news, I did get a 'supposedly correct' relay-server for outgoing SMTP mail and confirmed that emails sent from my domain name are going out through that server. I was also told that NO AUTHENTICATION is required. So now the question is whether to eliminate Username and Password OR use empty quotes (as they suggested). Still struggling here. PS to requinix: YES, while testing the outbound server to confirm that my mail was sending, I tested to my cell and it did display the sender's info. Quote Link to comment https://forums.phpfreaks.com/topic/308150-unable-to-send-text-to-metropcs-using-php-mail/#findComment-1563596 Share on other sites More sharing options...
requinix Posted January 16, 2019 Share Posted January 16, 2019 You can't add anything $mail at the top of your script because that variable doesn't exist yet! Quote Link to comment https://forums.phpfreaks.com/topic/308150-unable-to-send-text-to-metropcs-using-php-mail/#findComment-1563597 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.