PHP Contact Form problems

Recently I found out that the contact form on a site I designed had stopped working.

I researched it and saw the changes dreamhost had made.

To make a long story short, I’ve changed the from address to a dreamhost hosted email address, and I still can’t get the emails to go through.

My code is below, what am I doing wrong? I need help with this ASAP.
//set the recipient email address, where to send emails to
$email_to = ‘’;
//set the sender email address
$email_from = ‘’;
$errors = ‘’;
if(empty($_POST[‘name’]) ||
empty($_POST[‘title’]) ||
empty($_POST[‘address’]) ||
empty($_POST[‘city’]) ||
empty($_POST[‘state’]) ||
empty($_POST[‘email’]) ||
$errors .= “\n Error: all fields are required”;

$name = $_POST[‘name’];
$email_address = $_POST[‘email’];
$title = $_POST[‘title’];
$address = $_POST[‘address’];
$city = $_POST[‘city’];
$state = $_POST[‘state’];
$zip = $_POST[‘zip’];

if (!eregi(
$errors .= “\n Error: Invalid email address”;

if( empty($errors))
$to = $email_to;
$email_subject = “Media Request form submission: $name”;
$email_body = “You have received a new message. “.
” Here are the details:\n name: $name \n email: $email_address \n title: $title \n address: $address \n city: $city \n state: $state \n zip: $zip”;

$headers = "From: $email_from"; 
$headers .= "Reply-To: $email_address";

//redirect to the 'thank you' page
header('Location: mediarequest-form-thank-you.html');


Prayer Request form handler <?php echo nl2br($errors); ?>[/php]

This bit looks wrong:

[php] $headers = “From: $email_from”;
$headers .= “Reply-To: $email_address”;[/php]

There’s no newline separating the first header from the second one, so the header you end up sending looks like:

I’m not sure how this ends up getting interpreted by the mail server, but it’s definitely not right. Add a newline character ("\n") between the two to keep them separated:

[php]$headers = “From: $email_from\n”;
$headers .= “Reply-To: $email_address”;[/php]

If that doesn’t do the trick, maybe it’s something else I missed… reply back and I’ll have a closer look.

Andrew F.

That worked, thanks a bunch for your help.