Click to See Complete Forum and Search --> : mail() function not sending the from header


amrigo
04-28-2006, 09:07 AM
Hi

I have a script to send email but i always receive messages with the server default email in the from subject instead of the real email the user type in the email field :eek:

How it be fixed? :confused:

thank´s in advance

$cod=$_REQUEST['cod'];
$dpto = "some@email.com";
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$message=$_REQUEST['message'];
$to = $dpto;
$subject = "talk with us";
$headers = "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: " . $email . "\r\n";// <" . $name . ">
mail($to, $subject, $mensagem, $headers);
echo "Your message was sent!";

felgall
04-28-2006, 03:57 PM
Try swapping the headers around the other way so that the From header precedes the Content-type.

netcracker
04-29-2006, 01:33 AM
Do this. It will work:


$cod=$_REQUEST['cod'];
$dpto = "some@email.com";
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$message=$_REQUEST['message'];
$to = $dpto;
$subject = "talk with us";
// Change here
$headers = "From: " . $email . "\r\n";// <" . $name . ">
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
mail($to, $subject, $mensagem, $headers);
echo "Your message was sent!";


Hi

I have a script to send email but i always receive messages with the server default email in the from subject instead of the real email the user type in the email field :eek:

How it be fixed? :confused:

thank´s in advance

$cod=$_REQUEST['cod'];
$dpto = "some@email.com";
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$message=$_REQUEST['message'];
$to = $dpto;
$subject = "talk with us";
$headers = "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: " . $email . "\r\n";// <" . $name . ">
mail($to, $subject, $mensagem, $headers);
echo "Your message was sent!";

amrigo
04-29-2006, 01:20 PM
thank´s a lot i use Reply-To and it works
Best regards