views:

207

answers:

2

I've set up a local dev environment on snow leopard, and have set postfix up to send email via my isp mail server.

I eventually got postfix to work after much frustration, but now when my emails send the header information is bunged up!

I'm using the following php code:

$email = "me@mydomain";
$subject = "Email tester";
$body = "Simple test";
$header = "From: me@mydomain \r\n";
$header .= "MIME-VERSION: 1.0\r\n";
$header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$phpversion = phpversion();
$header .= "X-Mailer: PHP v$phpversion\r\n";
mail($email,$subject,$body,$header);

echo "message sent!";

The To: and Subject: headers display as they should, in the header!, but the rest display in the email body. This makes the email look like the from field in email client is empty.

I've tried a variety of php scripts, some very simple, but its the same thing, headers always displaying in the email body.

I'm thinking it could be a postfix problem, but not sure, anyone encountered this type of problem before?

+1  A: 

This is almost 100% not a Postfix problem, but something caused by your code. The body starts once a blank CRLF is seen after the headers.

You should dump out your email body text and see if you're not accidentally introducing an extra CRLF.

Joe
A: 

The same thing is happening to me...and I'm printing the body after the call to mail and it is correct. Why is header info being placed into the body?