Z_Smith Posted February 9, 2011 Share Posted February 9, 2011 I have been working a a program to send text messages using php but my headers containing the "From:" part of the text message keep on returning an error. Could someone please explain what i'm doing wrong. I have attached the php script and the html page I am using as a form. <?php $from = $_POST['from']; $to = $_POST['to']; $carrier = $_POST['carrier']; $carrierFrom = $_POST['carrierFrom'] $message = stripslashes($_POST['message']); //From Function if ($carrierFrom == "verizon") {$formatted_from = $from."@vtext.com";} if ($carrierFrom == "tmobile") {$formatted_from = $from."@tomomail.net";} if ($carrierFrom == "sprint") {$formatted_from = $from."@messaging.sprintpcs.com";} if ($carrierFrom == "att") { $formatted_from = $from."@txt.att.net"; if ($carrierFrom == "gmail") { $formatted_from = $from."@gmail.com"; } //To Function if ($carrierFrom == "verizon") {$formatted_number = $to."@vtext.com";} if ($carrier == "tmobile") {$formatted_number = $to."@tomomail.net";} if ($carrier == "sprint") {$formatted_number = $to."@messaging.sprintpcs.com";} if ($carrier == "att") {$formatted_number = $to."@txt.att.net";} if ($carrier == "gmail") {$formatted_number = $to."@gmail.com";} //Send $sent = mail($formatted_number,$message,$formattedFrom) ; if($sent) {print "Your text was sent successfully"; } else {print "We encountered an error sending your text"; } ?> [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/227118-sending-emailsms-with-php-error/ Share on other sites More sharing options...
Pikachu2000 Posted February 9, 2011 Share Posted February 9, 2011 What would the error be? Link to comment https://forums.phpfreaks.com/topic/227118-sending-emailsms-with-php-error/#findComment-1171649 Share on other sites More sharing options...
Z_Smith Posted February 9, 2011 Author Share Posted February 9, 2011 The "from:" header comes in as "anonymous". Link to comment https://forums.phpfreaks.com/topic/227118-sending-emailsms-with-php-error/#findComment-1171652 Share on other sites More sharing options...
Pikachu2000 Posted February 9, 2011 Share Posted February 9, 2011 The From: header should typically be set to a valid address on your mail server, and if a reply-to address is needed, a Reply-to: header would be added. But at any rate, where you define the $formattedFrom variable, if you're going to use it as a header, you need to define it as below, otherwise, it isn't recognized as a header; it's just an email address in a place it doesn't belong . . . $formattedFrom = 'From: ' . $from . '[then the carrier specific string]'; Link to comment https://forums.phpfreaks.com/topic/227118-sending-emailsms-with-php-error/#findComment-1171660 Share on other sites More sharing options...
trivikrama Posted February 9, 2011 Share Posted February 9, 2011 I think you have to use if.....elseif conditions Link to comment https://forums.phpfreaks.com/topic/227118-sending-emailsms-with-php-error/#findComment-1171723 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.