Problems with sending html emails using mail()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
holy0
Forum Newbie
Posts: 2
Joined: Fri Aug 02, 2002 5:05 am

Problems with sending html emails using mail()

Post by holy0 »

Hi I’m sending an html email using the mail() function, my problem is it seems to put a lot of ! in the html code. Is there anyway to stop this happening?

If I echo the email body rather than sending it , it works fine. Its only when I email it.

Any help would be appreciated.

Cut down version of the code is :


$headers .= "From: test <$re_email>\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1\n";

$email_body.="<table width=550 border=0 cellspacing=0 cellpadding=0 bgcolor=#dddddd class=products>";
$email_body.="<tr><td>Customers Details</td></tr>";
$email_body.="</table><br>";

mail("homer@simpson.com","test",$email_body,$headers);
User avatar
Zeceer
Forum Contributor
Posts: 136
Joined: Fri Aug 02, 2002 5:10 am
Location: Norway

Post by Zeceer »

Don't think you need 3 bodies?`Try this:

$headers .= "From: test <$re_email>\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1\n";

$email_body.="<table width=550 border=0 cellspacing=0 cellpadding=0 bgcolor=#dddddd class=products> <tr><td>Customers Details</td></tr> </table><br>";

mail("homer@simpson.com","test",$email_body,$headers);
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You need to send the e-mail with a MIME type check the man entry for mail() for all the headers that need to be set when sending HTML e-mail. Don't know if this'll solve the problem but it might help.

Zeceer - that shouldn't make any difference, all that he's doing is concenating the HTML so that he doesn't have to type it all on one line.

Mac
holy0
Forum Newbie
Posts: 2
Joined: Fri Aug 02, 2002 5:05 am

Post by holy0 »

Cheers for the help ... it doesn’t solve the problem. But I’m starting to think its outlook that has the problem.

I've just sent the email to a web based mail account and it looks fine. and has no ! at all .. a little strange..
Post Reply