Page 1 of 1

Tearing my hair out - HTML in email

Posted: Fri Dec 06, 2002 6:30 am
by alimax
Hi all

I am using the mail() function to generate emails all the time, I never have a problem with it. Now all emails I generate are not parsing the HTML, I have tried every combination of headers imaginable but still they appear in the mail and the HTML is not parsed, the main header I never neglect to include is $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

has anyone got any ideas where this is going wrong, my mail client receives HTML mail okay.

thanks :roll:

Posted: Fri Dec 06, 2002 6:41 am
by alimax
the version below works fine but has no HTML if I insert <a> tags around QUALIFY NOW and create a hyperlink to the site, all efforts of mine print <a href="www.Thesite.com/qualify">QUALIFY NOW</a> in the email, and yes before you ask I am escaping the quotes with \ so pse pse someone help...while I still have some hair

// build the friend's email...

$to = "$email";

$subject = "BIOTRAX ELIGIBILITY TEST $sender";

$body ="BIOTRAX ELIGIBILITY TESTING\r\n\r\nMessage from $sender: $note\r\n\r\nMAKE BETTER USE OF YOUR SPARE TIME.\r\n\r\nREGISTERING WITH US, THE ONLY UNITY OF VOLUNTEERS IN THE WORLD\r\n\r\nSEE IF YOU QUALIFY NOW\r\nBY CLICKING ON THIS LINK: http://www.Thesite.com/qualify\r\n";
$message="$body";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers = "From: $sender <$sender_email>\n";
$headers .= "Reply-To: <$sender_email>\n";
$headers .= "Return-Path: <$sender_email>\n";

// end email building..

// send the mail..

mail($to,$subject,$message,$headers);

Posted: Fri Dec 06, 2002 7:02 am
by volka
$headers = "From: $sender <$sender_email>\n";
you forgot the .
So there is no mime-type after this statement anymore ;)

Posted: Fri Dec 06, 2002 7:09 am
by alimax
Thanks for that, that defo would screw it up but having fixed that (and that wasn't in all of my efforts it is a recent cutnpaste "incident") I get this as my resulting email with the <a> tags showing:

Content-type: text/html; charset=iso-8859-1
From: Ali <ali@hooverburger.co.uk>
Reply-To: <ali@hooverburger.co.uk>


BIOTRAX ELIGIBILITY TESTING

Message from Ali: This had better work

MAKE BETTER USE OF YOUR SPARE TIME.

REGISTERING WITH US, THE ONLY UNITY OF VOLUNTEERS IN THE WORLD,
IS VERY REWARDING.

SEE IF YOU <a href="www.Thesite.com/qualify">QUALIFY NOW</a>

Posted: Fri Dec 06, 2002 7:39 am
by volka
I use this order of statements

Code: Select all

$headers = "MIME-Version: 1.0\n";
$headers .= "From: $sender <$sender_email>\n";
$headers .= "Reply-To: <$sender_email>\n";
$headers .= "Return-Path: <$sender_email>\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
and it's working as expected (in outlook express and mozilla)

Posted: Fri Dec 06, 2002 8:27 am
by alimax
I love you, why was this so different? I have not been aware of any need to order the headers and if such a need does exist does this not need pointing out somewhere?

Thanks a million :D