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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.