Page 1 of 1

Mailbody as attachment!!! fixable?

Posted: Fri Aug 04, 2006 3:53 am
by rubenc
Currently I am building a website, and all is doing well thanks to past experiences. However somehow, I end up with a stupid problem: the email message ends up as an attachment instead of just in the body of the mail where I'd like it to be.
I allready removed the \r in the $headers on purpose, otherwise this part ended up in the message part.
What am I doing wrong?

Code: Select all

$recipient="me@gmail.com";
$subject="Message from Ruben";
$body="this implies some mis-codign, why else is this in the attachment...";
$afzender="web@mydomain.nl";
$bcc="";

$headers  = "MIME-Version: 1.0\n";
$headers .= "Content-type: text; charset=iso-8859-1\n";

$headers .= "from: Me <".$afzender.">\n";
$headers .= "reply-to: ".$afzender." \n";
//$headers .="bcc:".  $bcc."\n";

$headers .= "X-Priority: 1\n";
$headers .= "X-Mailer: Etomite PHP mailer\n";



mail($recipient, $subject, $body,$headers);

return "mail verstuurd";

Posted: Fri Aug 04, 2006 5:08 am
by Chris Corbyn
Keep the \r in the headers.... it's needed.

Change content-type to "text/plain" -- not "text".

Always use the correct casing for the header:

"From: " not "from:"
"Bcc: " not "bcc:"
"Reply-To: " ... you get the idea

Always have a whitespace after the header name:

'Bcc: "Foo Bar" <Foo@Bar.com>' not 'Bcc:"Foo Bar" <Foo@Bar.com>'

I think your main issue is the content-type being invalid.

Posted: Fri Aug 04, 2006 5:12 am
by rubenc
Thanks, changing the content type did the job!
Topic closed