bschultz Posted August 1, 2008 Share Posted August 1, 2008 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. Link to comment https://forums.phpfreaks.com/topic/117740-solved-php-mail-to-send-an-sms-text-message/ Share on other sites More sharing options...
Rottingham Posted August 1, 2008 Share Posted August 1, 2008 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); } Link to comment https://forums.phpfreaks.com/topic/117740-solved-php-mail-to-send-an-sms-text-message/#findComment-605593 Share on other sites More sharing options...
bschultz Posted August 1, 2008 Author Share Posted August 1, 2008 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? Link to comment https://forums.phpfreaks.com/topic/117740-solved-php-mail-to-send-an-sms-text-message/#findComment-605618 Share on other sites More sharing options...
bschultz Posted August 2, 2008 Author Share Posted August 2, 2008 This was a Postfix config issue...not the php code. Thanks! Link to comment https://forums.phpfreaks.com/topic/117740-solved-php-mail-to-send-an-sms-text-message/#findComment-605823 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.