Jump to content
phppup

unable to send text to MetroPCS using PHP Mail

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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).

 

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

How would I be able to use one of those mailers?

Share this post


Link to post
Share on other sites

I suggest checking the documentation.

Share this post


Link to post
Share on other sites

So you're talking about setting up SMTP through Yahoo/Gmail etc.?

Am I on the right path?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.  

Share this post


Link to post
Share on other sites

...Do text messages via emails show you the sender's address? I don't think I've ever received any.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.
 

 

 

Share this post


Link to post
Share on other sites

You can't add anything $mail at the top of your script because that variable doesn't exist yet!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.