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

Bug #12914 PHP5 doesn't accept subjects containing \n in Function mail()
Submitted: 2008-01-15 21:03 UTC Modified: 2009-12-21 09:28 UTC
From: joliver Assigned: alec
Status: Closed Package: Mail_Mime (version 1.5.2)
PHP Version: 5.2.0 OS:
Roadmaps: 1.5.3    
Subscription  


 [2008-01-15 21:03 UTC] joliver (Oliver Jusinger)
Description: ------------ PHP5 doesn't accept subjects containing \n in Function mail() any more. "Subject of the email to be sent. Caution: This must not contain any newline characters, or the mail may not be sent properly." However Mail_Mime splits long subjects (especially with encoded special characters the subects becomes longer than 75 characters very soon). Result: no mail is sent at all. Your comment in mime.php: //determine the maximum length of such strings. //75 is the value specified in the RFC. As far as i've seen that's only a suggestion in RFC. Longer lines in mailheaders are perfectly valid, too. So please provide an option to turn off linebreaks in subjects. It seems that subjects containing \r\n are still accepted by mail() in PHP5. However postfix strictly requires \n http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=447074

Comments

 [2008-01-16 07:54 UTC] oliver (Oliver Jusinger)
This problem already seems to be solved in PHP 5.2.0-8+etch9. Mails with subjects containing \n are accepted now (they were not sent in 5.2.0-8-etch7). Therefore this bugreport might be closed or changed to a feature request (providing an option to turn of linebreaks in headers). Testcode for PHP mail() with a subject procuced by PEAR Mail_Mime: <?php $subject = "=?ISO-8859-1?Q?Bugreport_Debian_PHP_5.2.0-8+etch7_=F6=FC=E4_(sp?=\n =?ISO-8859-1?Q?ecial_Characters)?="; $to = 'xyz@xyz.xyz'; $body = 'foo'; $header = 'From: xyz@xyz.xyz'; var_dump(mail($to, $subject, $body, $header)); ?>
 [2008-01-16 08:29 UTC] oliver (Oliver Jusinger)
My first 2 messages didn't explain the problem properly, here finally the facts: 1) postfix only accepts \n in headers. \r\n breaks the mailheader, because postfix rewrites \n to \r\n 2) In Mail_Mime, header linebreaks are hardcoded \r\n - this is RFC valid, however on unix systems \n to \r\n convertion is often done by the mailserver: A discussion about the \r\n problem: http://bugs.php.net/bug.php?id=15841 Result: the combination Pear::Mail_Mime and postfix doesn't work. Quick workaround: add the following line at row 103 in Mail.php $subject = str_replace("\r\n", "\n", $subject); Feature wish: configurable linebreak for headers. Sorry for my first 2 unclear messages...
 [2008-01-16 08:46 UTC] oliver (Oliver Jusinger)
A last hint ;-) In PHP 4, \r\n in subjects is replaced by \n, therefore Mail_Mime worked. In PHP 5 \r\n doesn't get replaced by \n any more.
 [2009-12-18 09:05 UTC] alec (Aleksander Machniak)
RFC2822, defines folding separator as CRLF, so I don't see a bug in Mail_Mime here.
 [2009-12-21 09:28 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. Now, MAIL_MIME_CRLF separator is used instead of hardcoded "\r\n" which should fix this issue.