Exclamation marks appearing in HTML email
Posted by Streetdaddy™ on November 11th, 2008 filed in GeekIf you’re getting random exclamation marks appearing in the source of HTML emails being sent using PHP’s built in mail() function, then your HTML may be exceeding the maximum line length (998) specified in RFC 2822 Internet Message Format.
I found the easiest way to deal with it is to use the PHP function wordwrap(), eg.
$someHtml = wordwrap($someHtml, 996);
mail(“someone@somewhere.com”, “My subject”, $someHtml, “MIME-Version: 1.0;\nContent-type: text/html; charset=iso-8859-1;\nFrom: someone@somewhere.com\n”);
I discovered this while I was tidying up some of the email templates for a web application at my work. There’s a long list of defects perpetrated by previous contributors, and I was tearing my hair out trying to work out why the content of a random table cell refused to center. So now I have a greater appreciation for HTML email template designers, or maybe I just feel sorry for them…

2 Responses to “Exclamation marks appearing in HTML email”
Leave a Comment