Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: Email not sending when using variables in header

xX4m4zingXx:

I am creating a contact form and for some reason when I use variables int he header, the email isn't getting sent. This one works:


$first_name = (isset($_POST['firstname']) ? $_POST['firstname'] : null);
$last_name = (isset($_POST['lastname']) ? $_POST['lastname'] : null);
$email = (isset($_POST['email']) ? $_POST['email'] : null);
$message = (isset($_POST['message']) ? $_POST['message'] : null);
$mail_to = "MyEmail";
$subject = "Subject";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'From: Your name ' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($mail_to, $subject, $message, $headers)

and this one doesn't


$first_name = (isset($_POST['firstname']) ? $_POST['firstname'] : null);
$last_name = (isset($_POST['lastname']) ? $_POST['lastname'] : null);
$email = (isset($_POST['email']) ? $_POST['email'] : null);
$message = (isset($_POST['message']) ? $_POST['message'] : null);
$mail_to = "MyEmail";
$subject = "Subject";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'From: ' . $first_name . ' ' . $last_name . ' ' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($mail_to, $subject, $message, $headers)

I am talking about these lines:


$headers .= 'From: Your name ' . "\r\n";
$headers .= 'From: ' . $first_name . ' ' . $last_name . ' ' . "\r\n";



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: Email not sending when using variables in header

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×