note 20136 added to function.mail
| From: | bandit at surfnonstop dot com | Date: | Sat, 23 Mar 2002 16:55:33 +0000 |
| Subject: | note 20136 added to function.mail | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-28124@lists.php.net to get a copy of this message | ||
I was investigating line ending convention problems under Linux with PHP.
I wrote a script sending out email according to RFC822 and to the above documentation of
additional_heders in mail(): lines should end with \r\n characters.
We started sending out emails, but we got some bounces from certain remote servers: they refused
application-generated header lines in mails sent with PHP's mail() function, complaining of
illegal characters.
Technical support on the remote end was kind enough to diagnose presence of trailing \r characters
in named header lines.
Upon checking source code of PHP-4.0.6, PHP-4.1.2 and PHP-4.2.0-RC1, it turned out that - WIN32
excepted - the mail() function (actually the internal php_mail function) ends generated header lines
with a single \n character, and does no line-ending conversion.
So the application-provided \r\n ended lines got mixed together with the PHP-provided \n ended lines
when getting sent to the underlying mailer.
I haven't investigated postfix deeper, but I assume it converts \n line endings into \r\n
internally so that's why PHP sends only \n line endings.
In this situation the documentation is misleading for non WIN32 platforms at least, as it stresses
the need of using \r\n as line ending in headers, which - together with the only \n method in the
PHP source - results in mixed line endings, and apparently in some cases causes mail to bounce.
I'd suggest the documentation be brought in sync with/extended regarding how mail() behaves wrt
line endings under non WIN32 platforms.
--
http://www.php.net/manual/en/function.mail.php
http://master.php.net/manage/user-notes.php?action=edit+20136
http://master.php.net/manage/user-notes.php?action=delete+20136
http://master.php.net/manage/user-notes.php?action=reject+20136