Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.8.8

Bug #12032 html emails don't display properly in Outlook 2003
Submitted: 2007-09-12 06:23 UTC Modified: 2008-03-22 23:50 UTC
From: therod Assigned: cipri
Status: Closed Package: Mail_Mime (version 1.5.2)
PHP Version: 4.4.7 OS: Linux
Roadmaps: 1.5.3    
Subscription  


 [2007-09-12 06:23 UTC] therod (Rod Holland)
Description: ------------ Using Pear Package version: 1.4.10 I am using Pear Mime class to send emails to clients. I have a plaintext.php template file with variables to be replaced with values. I also have a htmltext.php template file with variables in it to be replaced by values. I set the plaintext code first and then the html. The resulting html email version displays fine in Outlook 2000 but DOES NOT display properly in Outlook 2003. It comes out like this: boundary="=_d4882b8300c42af6f68a0346e6b5e13a" Message-Id: <20070912100339.B3D4D1EC0B7@roland.iserve.net.nz> Date: Wed, 12 Sep 2007 22:03:39 +1200 (NZST) --=_d4882b8300c42af6f68a0346e6b5e13a Content-Type: multipart/alternative; boundary="=_626fa01c7b9cf37a03a8331e5a1088ff" --=_626fa01c7b9cf37a03a8331e5a1088ff Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Good morning , It is now time to start thinking about the content you would like to place in your outgoing newsletter! To add the content, open the attachment, fill in the details and send it to SOME EMAIL TEXT REPLACE FOR CONFIDENTIALLITY --=_626fa01c7b9cf37a03a8331e5a1088ff Content-Type: text/html; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable <html> <head> <style> body { BACKGROUND-POSITION: left top; MARGIN-TOP: 150px;=20 FONT-WEIGHT: bold; FONT-SIZE: 12pt;=20 COLOR: #000000; BACKGROUND-REPEAT: no-repeat;=20 FONT-FAMILY: Arial;BACKGROUND-COLOR: #ffffff; } p.emailformatting, li.emailformatting, div.emailformatting {margin:0in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Calibri","sans-serif";} =20 =20 </style> </head> <body style=3D"color: #000080;margin: 0cm 0cm 0pt;"> Test script: --------------- $pearDir = 'DIRECTORY FOR PEAR'; //need DEBUGGE TO SET THIS $path = $pearDir; set_include_path(get_include_path() . PATH_SEPARATOR . $path);//get the PEAR package require_once($pearDir.'Mail.php'); require_once($pearDir.'Mail/mime.php'); $to = "email@gmail.com"; $mime = new Mail_mime; $headers['From'] = "email@gmail.com"; $clientName = "Fred Fish"; include("htmltext_template.php"); $htmlText = $htmlmessage; include("plaintext_template.php"); $plaintext = $plainmessage; $mime ->setTXTBody($plaintext);//assemble the plain text version $mime->setHTMLBody($htmlText); //assemble the html version $headers['Subject'] = 'Some test subject' ;//add the subject $file = "/LOCATION OF FILE TO BE FILLED IN BY DEBUGGER"; $mime->addAttachment($file,'application/msword');//add the attachment //get mime formatted message headers and body $body = $mime->get(); $emailheaders = $mime->headers($headers); $sending_message =& Mail::factory('mail'); $sending_message->send($to, $emailheaders, $body);//send the email ---------------"htmltext_template.php"--------- $htmlmessage='<html> <head> <style> body { BACKGROUND-POSITION: left top; MARGIN-TOP: 150px; FONT-WEIGHT: bold; FONT-SIZE: 12pt; COLOR: #000000; BACKGROUND-REPEAT: no-repeat; FONT-FAMILY: Arial;BACKGROUND-COLOR: #ffffff; } </style> </head> <body style="color: #000080;margin: 0cm 0cm 0pt;"> Good morning '.$clientName.'<br> <p style="margin-top: 0;margin-bottom:0;">It is now time to start thinking about the content you would like to place in your<br> outgoing newsletter!</p><br> <br></body> </html>'; ---------------"htmltext_template.php"--------- ----------------"plaintext_template.php"---------- $plainmessage='Good morning '.$clientName.' It is now time to start thinking about the content you would like to place in your outgoing newsletter!'; ----------------"plaintext_template.php"---------- Expected result: ---------------- Display like in Internet Explorer Actual result: -------------- boundary="=_d4882b8300c42af6f68a0346e6b5e13a" Message-Id: <20070912100339.B3D4D1EC0B7@roland.iserve.net.nz> Date: Wed, 12 Sep 2007 22:03:39 +1200 (NZST) --=_d4882b8300c42af6f68a0346e6b5e13a Content-Type: multipart/alternative; boundary="=_626fa01c7b9cf37a03a8331e5a1088ff" --=_626fa01c7b9cf37a03a8331e5a1088ff Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Good morning , It is now time to start thinking about the content you would like to place in your outgoing newsletter! To add the content, open the attachment, fill in the details and send it to SOME EMAIL TEXT REPLACE FOR CONFIDENTIALLITY --=_626fa01c7b9cf37a03a8331e5a1088ff Content-Type: text/html; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable <html> <head> <style> body { BACKGROUND-POSITION: left top; MARGIN-TOP: 150px;=20 FONT-WEIGHT: bold; FONT-SIZE: 12pt;=20 COLOR: #000000; BACKGROUND-REPEAT: no-repeat;=20 FONT-FAMILY: Arial;BACKGROUND-COLOR: #ffffff; } p.emailformatting, li.emailformatting, div.emailformatting {margin:0in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Calibri","sans-serif";} =20 =20 </style> </head> <body style=3D"color: #000080;margin: 0cm 0cm 0pt;">

Comments

 [2007-09-13 12:36 UTC] stephenbigelis (Stephen Bigelis)
This issue has come up before. It has to do with PHP_EOL, if this global(?) is not defined, Mail_Mime is going to assume it is running on a windows os and define it as "\r\n", which on unix systems will create the double line breaks in the header. I have always had bad luck with PHP_EOL on the shared hosts which I often work, so I just went through the mail_mime.php file and took out all the \r's from both the defining of PHP_EOL and from and $eol vars and it worked fine. Of course it is no longer portable, but in my case it doesn't need to be. FYI windows uses "\r\n" mac uses "\r" linux uses "\n" Hope this helps. _Stephen
 [2007-09-13 18:57 UTC] stephenbigelis (Stephen Bigelis)
I wanted to correct my earlier post, I just checked my MAC and it was "\n" not "\r", which I got from the internet...Go Figure.. Anyway something like this might clear things up for you.. if (!defined('PHP_EOL')) define ('PHP_EOL', strtoupper(substr(PHP_OS,0,3) === 'WIN') ? "\r\n" : "\n");
 [2007-09-14 01:21 UTC] therod (Rod Holland)
Thanks for that Stephen I will test it tonight when a freind who has Outlook 2003 gets home. Thanks once again
 [2007-10-05 17:22 UTC] cipri (Cipriano Groenendal)
Not enough information was provided for us to be able to handle this bug. Please re-read the instructions at http://bugs.php.net/how-to-report.php If you can provide more information, feel free to add it to this bug and change the status back to "Open". Thank you for your interest in PEAR. Does setting the correct PHP_EOL fix this problem?
 [2007-10-12 23:28 UTC] therod (Rod Holland)
It has not completely solved my problem. It fixed it a little by not having so much messy bits but still shows both the plain text and html code in the email. Not sure where to put the if (!defined('PHP_EOL')) define ('PHP_EOL', strtoupper(substr(PHP_OS,0,3) === 'WIN') ? "\r\n" : "\n"); I placed it in the mime.php script before the require mimePart.php statement and also in the mimePart.php script within the class structure but not in a function and then uploaded both these files into both the mail folder and mime folder.
 [2007-10-12 23:30 UTC] therod (Rod Holland)
Also still shows some of the boundary markers. P.S. Sorry I didn't get back to the forum quicker, just been having a few things go wrong lately that have occupied my time.
 [2007-11-06 11:16 UTC] fatmoon (Al Buss)
Mail_Mime 1.5.2 stable All of these issues only seem to appear in Outlook When using "quoted-printable" the message would wrap and display much of the characters incorrectly. Then I tried "7bit" and then my html displayed correctly except for at the end of the message it displayed "</html" My solution is using "7bit" and had to alter line 258 of mimePart.php by adding a ". MAIL_MIMEPART_CRLF" from: rtrim(implode('--' . $boundary . MAIL_MIMEPART_CRLF , $subparts), MAIL_MIMEPART_CRLF) . to: rtrim(implode('--' . $boundary . MAIL_MIMEPART_CRLF , $subparts), MAIL_MIMEPART_CRLF) . MAIL_MIMEPART_CRLF . it seems Microsoft needs to see a blank line between the end of the html and the boundary. I haven't noticed that this causes a problem in any other email client.
 [2007-11-09 17:12 UTC] stephenbigelis (Stephen Bigelis)
Could you post what the raw email looks like in outlook currently? (post PHP_EOL fix)
 [2007-11-17 19:28 UTC] therod (Rod Holland)
POST PHP_EOL fix boundary="=_1038385b200886de5733765274cf911f" Message-Id: <20071117062849.613AE1EC0CE@roland.iserve.net.nz> Date: Sat, 17 Nov 2007 19:28:49 +1300 (NZDT) --=_1038385b200886de5733765274cf911f Content-Type: multipart/alternative; boundary="=_01103bba09af835dee73e58b82e3c4fd" --=_01103bba09af835dee73e58b82e3c4fd Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Good morning , It is now time to start thinking about the content you would like to place in your outgoing newsletter! To add the content, open the attachment, fill in the details and send it to Permission Marketing at mailto:Roderick Holland Please call myself on PH: 09 222 2222, should you have any questions. Kind regards, Roderick Holland Date Reminders 1st reminder (12th August Thursday) 2nd reminder (12th August Thursday) Due Date for Proof (12th August Thursday) Sending the newsletter date (12th August Thursday) SOME ONE CEO, Permission Marketing 24 HR Office: 09 222 2222 Cell 022 2222 2222 PO Box 222, Greenhithe, Auckland, New Zealand. Permission Marketing works with Associations & Businesses to get Interaction and Response to build a fantastic relationship with their customers; You can now Send out Surveys, Get your members to provide feedback on polls and send out good looking Email Newsletters, so your customers Know, Trust and Like you. --=_01103bba09af835dee73e58b82e3c4fd Content-Type: text/html; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable
Good morning

It is now time to start thinkin= g about the content you would like to place in your
outgoing newsletter!


To add the content, open the attachment, fill in the details and send it to
Permission Marketing at ">Roderick Holland


Please call myself on PH: 09 22= 2 2222, should you have any questions.


Kind regards,
Roderick Holland

Date Reminders
1st reminder ( 12 th August Thursday =20 )
2nd reminder ( 12th August Thursday)
Due Date for Proof ( 12th August Thursday )
Sending the newsletter date ( 12th August Thursday)


SOME ONE

CEO, Permissi= on Marketing

24 HR Office:= 09 2222 22222 Cell 02222222222

PO Box 139, , Auckland, New Zealand.

 =

Permission Ma= rketing works with Associations & Businesses to get Interaction and Response to build a fantastic relationship with their customers;= You can now Send out Surveys, Get your members to provide feedback on polls and send out good looking Email Newsletters, so your customers Know, Trust and = Like you.

<br></body> </html> --=_01103bba09af835dee73e58b82e3c4fd-- --=_1038385b200886de5733765274cf911f Content-Transfer-Encoding: base64 Content-Type: application/msword Content-Disposition: attachment; filename="Monthly System.doc" 0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAAFAAAAKgIAAAAA AAAA EAAALAIAAAEAAAD+////AAAAACUCAAAmAgAAJwIAACgCAAApAgAA//////////////////// //// //////////////////////////////////////////////////////////////////////// //// //////////////////////////////////////////////////////////////////////// //// //////////////////////////////////////////////////////////////////////// //// //////////////////////////////////////////////////////////////////////// //// //////////////////////////////////////////////////////////////////////// //// //////////////////////////////////////////////////////////////////////// //// //////////////////////////////////////////////////////////////////////// ///s pcEANUAJBAAA+BK/AAAAAAAAEAAAAAAABgAAhhcAAA4AYmpias8yzzIAAAAAAAAAAAAAAAAA AAAA
 [2007-11-19 10:31 UTC] stephenbigelis (Stephen Bigelis)
So it looks like it is putting an extra line break throughout the whole email. Got a couple of ideas for you... Try $mime = new Mail_mime("\n"); If this works you should then replace it with for portability. $mime = new Mail_mime(PHP_EOL); I believe this will set your EOL to "\n" for the entire construct. Also if you have no luck with this you could try Defining (MAIL_MIMEPART_CRLF or MAIL_MIME_CRLF) as "\n" prior to creating the new Mail_mime. Try the first one and see what happens though it might break it in other agents, so do a full test. Also, do you know what mailer you are using (Q-mailer?) check your headers it should say.
 [2007-11-19 18:42 UTC] therod (Rod Holland)
IT WORKS!!!!! Thanks stephen.bigelis you solved my problem. ##QUOTE## So it looks like it is putting an extra line break throughout the whole email. Got a couple of ideas for you... Try $mime = new Mail_mime("\n"); ##QUOTE## Thank you Al Buss for your suggestions too. Not sure what my mailer is as I couldn't find it in the headers. Thanks again!!!!!
 [2008-03-22 23:50 UTC] doconnor (Daniel O'Connor)
Closing, because Rod's problem is solved. Cipri, is this worth putting in documentation of some description? Or is there an underlying bug that needs to be addressed?