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

Bug #16539 Long headers break mime body display
Submitted: 2009-08-20 01:15 UTC
From: skibster Assigned: alec
Status: Closed Package: Mail_Mime (version 1.5.2)
PHP Version: 5.1.2 OS: 10.3.9
Roadmaps: 1.5.3    
Subscription  


 [2009-08-20 01:15 UTC] skibster (Jim Skibbie)
Description: ------------ If the To header is set in a mixed message text/html, and the header is longer than 998 characters, the email body is displayed as the source text instead of as HTML. According to RFC 2822, there is a method for 'folding' long headers. This should be implemented to avoid this issue. Test script: --------------- <?php require('Mail.php'); require('Mail/mime.php'); $smtpRelay = 'smtp.example.com'; $smtpPort = 25; $crlf = "\r\n"; $headers['To'] = "jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com"; $headers['From'] = "jskibbie@schawk.com"; $headers['Subject'] = "This is the Subject"; $headers['Reply-To'] = $headers['From']; $headers['X-Mailer'] = 'PHP 5.x'; $params["host"] = $smtpRelay; $params["port"] = $smtpPort; $textMsg = "A Low Resolution PDF is ready for review. Please use this link download a compressed archive of the PDF file: http://thisisthelink.com"; $htmlMsg =' <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"> <title>'.$headers['Subject'].'</title> </head> <body> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td> A Low Resolution PDF is ready for review.<br /><br /> <a href="http://thisisthelink.com">This is the link</a><br /><br /> </td> </tr> </table> </body> </html>'; $mail_object =& Mail::factory('smtp', $params); $mime = new Mail_mime($crlf); $mime->setTXTBody($textMsg); $mime->setHTMLBody($htmlMsg); $mailGetParam["text_encoding"] = "7bit"; $mailGetParam["html_encoding"] = "quoted-printable"; $mailGetParam["html_charset"] = "ISO-8859-1"; $body = $mime->get($mailGetParam); $hdrs = $mime->headers($headers); $mailResult = $mail_object->send($headers['To'], $hdrs, $body); ?> Expected result: ---------------- An email that has a properly formatted To and Subject and the body looks like this: A Low Resolution PDF is ready the review. This is the link (where the link is an HTML anchor tag). Actual result: -------------- An email that has no "To" or "Subject", and the body is raw source. Received: from smtp.example.com ([127.0.0.1]) by some.smtp.example.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 19 Aug 2009 13:44:12 -0500 Received: from localhost ([10.26.26.168]) by some.smtp.example.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 19 Aug 2009 13:44:12 -0500 MIME-Version: 1.0 From: JSkibbie@schawk.com Bcc: Return-Path: JSkibbie@schawk.com Message-ID: <CORPEXCH013E1ioWwr20000010a@some.smtp.com> X-OriginalArrivalTime: 19 Aug 2009 18:44:12.0052 (UTC) FILETIME=[0B381540:01CA20FD] Date: 19 Aug 2009 13:44:12 -0500 To: jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskib bie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@ schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@scha wk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.co m,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jsk ibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie @schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@sch awk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.c om,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,js kibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbi e@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@sc hawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk .com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com, jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskib bie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@ schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@scha wk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.co m,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jsk ibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie @schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@sch awk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.c om,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,js kibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbi e@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@sc hawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk .com,jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com, jskibbie@schawk.com,jskibbie@schawk.com,jskibbie@schawk.com,jskib bie@schawk.com,jskibbie@schawk.com From: jskibbie@schawk.com Subject: This is the Subject Reply-To: jskibbie@schawk.com X-Mailer: PHP 5.x Content-Type: multipart/alternative; boundary="=_522c61ee6f7504b0b1319875c844a01a" Return-Path: jskibbie@schawk.com Message-ID: <CORPEXBH02llNY30kkZ00000ae6@some.smtp.com> X-OriginalArrivalTime: 19 Aug 2009 18:44:12.0207 (UTC) FILETIME=[0B4FBBF0:01CA20FD] Date: 19 Aug 2009 13:44:12 -0500 --=_522c61ee6f7504b0b1319875c844a01a Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="ISO-8859-1" A Low Resolution PDF is ready for review. Please use this link download a compressed archive of the PDF file: http://thisisthelink.com --=_522c61ee6f7504b0b1319875c844a01a Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="ISO-8859-1" <html> <head> <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DISO-88= 59-1"> <title>This is the Subject</title> <style type=3D"text/css" media=3D"screen"> /* <![CDATA[ */ body{ font: 12px Arial,Helvetica,Verdana,Sans-serif; } a{ font-size: .9em; } a:link{ text-decoration: none; } a:visited { text-decoration: none; } a:hover { text-decoration: none; color: orange; border-bottom: 2px dotted orange; } a:active { color: red; border-bottom: 2px dotted red; } /* ]]> */ </style> </head> <body> <table border=3D"0" cellspacing=3D"0" cellpadding=3D"0"> <tr> <td> A Low Resolution PDF is ready for review.<br /><br /> <a href=3D"http://thisisthelink.com">This is the link</a><br / ><br /> </td> </tr> </table> </body> </html> --=_522c61ee6f7504b0b1319875c844a01a--

Comments

 [2009-08-20 03:51 UTC] skibster (Jim Skibbie)
This issue was solved by using the 'folding' technique outlined in RFC 2822. 2.2.3. Long Header Fields Each header field is logically a single line of characters comprising the field name, the colon, and the field body. For convenience however, and to deal with the 998/78 character limitations per line, the field body portion of a header field can be split into a multiple line representation; this is called "folding". The general rule is that wherever this standard allows for folding white space (not simply WSP characters), a CRLF may be inserted before any WSP. For example, the header field: Subject: This is a test can be represented as: Subject: This is a test so taking an array of email addresses and creating the comma separated string, but instead of just inserting a comma, you insert ",\r\n ". to create the CRLF in front of a whitespace character. $recipients = implode(",\r\n ", $emailArray); instead of $recipients = implode(",", $emailArray);
 [2009-12-21 14:25 UTC] alec (Aleksander Machniak)
-Status: Open +Status: Closed -Assigned To: +Assigned To: alec -Roadmap Versions: +Roadmap Versions: 1.5.3
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.