Jump to content

[SOLVED] PHP Mail to send an sms text message


bschultz

Recommended Posts

I'm trying to use PHP mail to send a text message to a phone...not very hard, and it's "somewhat" working.  The only issue that I'm having is the headers aren't right.  The text message is saying that it's from "[email protected]" instead of "[email protected]"

 

Here's the code:

 


<?
$message = $_POST["text"];


//build peices of the email message
$subject = "Subject: My Subject";
$to = $_POST["number"];

//replace 'phone-x' with a working cell phone number
$rec = array("[email protected]", "[email protected]" , "[email protected]" , "[email protected]");
$headers = 'From: [email protected] . "\r\n" . "Reply-To: my_cell_phone_number" . "\r\n\n" ';


//send the sms email
foreach ($rec as $r) {
mail ($r,$subject,$message,$headers);


//close foreach
}

echo '$r,$subject,$message,$headers <meta http-equiv=Refresh content=10;url="sendtxt.php">';

?>

 

Can someone please tell me what I'm doing wrong here?

 

Thanks.

Just like email, it is all about your headers!

 

I took your code (thank you by the way, gave me a great idea. For more email servers for text messages, visit http://www.livejournal.com/tools/textmessage.bml?mode=details .

 

I altered the headers and it works beautifully. Also, make sure that the FROM email address or send from email address is a VALID email address on the account. If your FROM header is not your email address, use the following code before sending emails:

 

ini_set("sendmail_from", "[email protected]");  // the INI lines are to force the From Address to be used !

 

$subject = "Subject: My Subject";
$headers .= "Reply-To: my_reply_number\n";
$headers .= "From: My web server <[email protected]>\n";
$message = "I'm sending you text messages from our server! Great feature!";

//send the sms email
foreach ($rec as $r) 
{
     mail ($r,$subject,$message,$headers); 
}

Still doesn't work...

 

$subject = "Subject: Score Updates";
$headers .= "Reply-To: [email protected]\n";
$headers .= "From: my name <[email protected]>\n";

//send the sms email
foreach ($rec as $r) 
{
     mail ($r,$subject,$message,$headers); 
}
echo $r, $subject, $message, $headers;
echo '<meta http-equiv=Refresh content=10;url="http://mydomain.com/sendatext.php">';

 

I still get the message...but it still says it's coming from [email protected]

 

Thanks for the help...any other other ideas?

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

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.