Zen Cart email woes with Postfix MTA
I've been working on setting up a Zen Cart shopping cart on my companies web server.
The installation was easy, however I've been having trouble with the formatting of the emails sent from the shopping cart to my test customer accounts and the emails sent to my admin email account.
The emails are supposed to show up as HTML emails, instead they show up as text with all the HTML code in the body of the email. If I change to Text only emails, the body of the email doesn't have any line breaks.
Here's a sample
Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bitI couldn't find any love on the Zen Cart site, although I did get someone who responded with "I'm having the same problem".
Order Confirmation from My Store John Doe Thanks for shopping with us today! The following are the details of your order.
------------------------------------------------------ Order Number: 8 Date Ordered: Tuesday 23 August, 2005 Detailed Invoice: https://www.mystore.com/catalog/index.php?m...info&order_id=8 Please ship it -1 day air! Well, it's not here yet.
I google'd around and came across this page on Php.net, and this particular entry:
php at richardneill dot org
12-Jul-2004 07:09Postfix under Mandrake 10.0 also objects to \\r\\n. The result is that every email is double-spaced, and all attachments break. (it was OK in 9.1). My (short-term) fix is this:
$message = str_replace("\r",'',$message);
This discussion may be relevant:
http://www.phpdiscuss.com/article.php?id=60615&group=php.bugs
I made the following change to the sendmail portion of the code (the comments are the original code):
Notice that I simply replaced "\r\n" with "\n".
if (EMAIL_FRIENDLY_ERRORS=='true') {
//return @mail($to, $subject, preg_replace("#(?<!\r)\n#s","\r\n", $this->output), $headers_list);
return @mail($to, $subject, preg_replace("#(?<!\r)\n#s","\n", $this->output), $headers_list);
} else {
//return mail($to, $subject, preg_replace("#(?<!\r)\n#s","\r\n", $this->output), $headers_list);
return mail($to, $subject, preg_replace("#(?<!\r)\n#s","\n", $this->output), $headers_list);
}
Preliminary tests have shown that this change has fixed the problem with the HTML and Plain Text emails.