Edit report at http://pear.php.net/bugs/bug.php?id=12914&edit=1
ID: 12914
Comment by: alec@alec.pl
Reported By: joliver at gmx dot at
Summary: PHP5 doesn't accept subjects containing \n in
Function mail()
Status: Open
Type: Bug
Package: Mail_Mime
Package Version: 1.5.2
PHP Version: 5.2.0
Roadmap Versions:
New Comment:
RFC2822, defines folding separator as CRLF, so I don't see a bug in
Mail_Mime here.
Previous Comments:
------------------------------------------------------------------------
[2008-01-16 08:46:15] oliver
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.
------------------------------------------------------------------------
[2008-01-16 08:29:56] oliver
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 07:54:25] oliver
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-15 21:03:37] joliver
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
------------------------------------------------------------------------