From: hannibal at astral dot lodz dot pl
Operating system: Linux
PHP version: 5.2.9
PHP Bug Type: Mail related
Bug description: schizophrenic behaviour of adding EOL indicator in mail().
Description:
------------
Diffrent parts of mail function use LF some CRLF. This cause headers
to have mixed LF & CRLF endings. This can casue in some situation
broken mail delivery. PLEASE do not tell this is MTA problem. This is
also your concer to PROVIDE MTA standard compilant headers or at
least do this in consistent way.
Details:
ext/standard/mail.c (PHP 5.2.9) line 147
SKIP_LONG_HEADER_SEP(to_r, i);
This code assume that user provide CRLF line ending. If user provide
LF only, it is replace by spaces - so it cannot be used.
ext/standard/mail.c (PHP 5.2.9) line 273-278
fprintf(sendmail, "To: %s\n", to);
fprintf(sendmail, "Subject: %s\n", subject);
if (headers != NULL) {
fprintf(sendmail, "%s\n", headers);
}
fprintf(sendmail, "\n%s\n", message);
This cleanly show that headers added automatially by PHP are always
ended by LF only.
In case, where subject is multline, headers always have mixed CRLF
and LF. This cause Postfix to left CR in header lines that have it.
It can cause probles where buggy Qmail is recipent, it replaces alone
CR to empty line, which causes premature end of headers in recipent
mail program. Again this is also YOUR PROBLEM, MTA must only properly
handling RFC compilant data - when other is sended, behaviour can be
undefined.
There is a couple methods to fix it, more or less properly.
1. Add "\r" to fprintf - RFC compilant but probably broke many apps
which use LF only header endings.
2. Add support to LF ending to SKIP_LONG_HEADER_SEP - also quite
easy, but not necessery best.
3. Add prameter to mail function in which user provide desired EOL -
best some enum (LEGACY - current buggy, CRLF - RFC compilant, LF -
unix compilant)
4. Configuration parameter whith same values as above.
--
Edit bug report at http://bugs.php.net/?id=47983&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=47983&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=47983&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=47983&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=47983&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=47983&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=47983&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=47983&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=47983&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=47983&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=47983&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=47983&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=47983&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=47983&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=47983&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47983&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=47983&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=47983&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=47983&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=47983&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=47983&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=47983&r=mysqlcfg