Jump to content

Sending Email/SMS with php Error


Z_Smith

Recommended Posts

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

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]';

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.