#20340 [Opn]: mail() incorrectly strips multiple \r\n
| From: | _ at mrmachine dot net | Date: | Sun, 10 Nov 2002 17:10:11 +0000 |
| Subject: | #20340 [Opn]: mail() incorrectly strips multiple \r\n | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-24439@lists.php.net to get a copy of this message | ||
ID: 20340
User updated by: _@mrmachine.net
Reported By: _@mrmachine.net
Status: Open
Bug Type: Mail related
Operating System: Windows XP SP1
PHP Version: 4CVS-2002-11-10
New Comment:
the bug system seems to have entered an erroneous carriage return on
line 7 of my example code.
Previous Comments:
------------------------------------------------------------------------
[2002-11-10 11:04:58] _@mrmachine.net
tested on 4.3pre2 and 4.3-snapshot (2002-11-10).
php4/win32/sendmail.c contains:
/* This pattern removes \r\n from the start of the string,
* \r\n from the end of the string and also makes sure every line
* is only wrapped with a single \r\n (thus reduces multiple
* occurences of \r\n between lines to a single \r\n) */
#define PHP_WIN32_MAIL_RMVDBL_PATTERN "/^\r\n|(\r\n)+$/m"
#define PHP_WIN32_MAIL_RMVDBL_REPLACE ""
i'm not certain if the applicable specification(s) require that there
be NO multiple occurences of \r\n in a mime message, but this addition
has broken compatibility with outlook express clients at the very
least, which seems to depend on multiple \r\n to separate content
blocks.
it will also unecessarily alter valid mail content, and therefore i
believe \r\n should only be stripped from the beginning and end of the
message, if at all.
example code:
--cut--
$headers = 'From: _@mrmachine.net' . "\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-Type: multipart/mixed;' . "\r\n";
$headers .= ' boundary="703c1875a9605c5619dd34f7642dcad8"' . "\r\n";
$headers .= 'Content-Transfer-Encoding: 7bit' . "\r\n\r\n";
$headers .= 'This is a multi-part message in MIME format.' .
"\r\n\r\n";
$headers .= '--703c1875a9605c5619dd34f7642dcad8' . "\r\n";
$headers .= 'Content-Type: text/html;' . "\r\n";
$headers .= ' charset="iso-8859-1"' . "\r\n";
$headers .= 'Content-Transfer-Encoding: 7bit' . "\r\n\r\n";
$headers .= '<pre>' . "\r\n";
$headers .= 'test paragraph 1' . "\r\n\r\n";
$headers .= 'test paragraph 2' . "\r\n";
$headers .= '</pre>' . "\r\n\r\n";
$headers .= '--703c1875a9605c5619dd34f7642dcad8--' . "\r\n";
mail('_@mrmachine.net', 'test', null, $headers);
--cut--
the above code will deliver a seemingly empty email. if the message
source is viewed, you will find that even had the content been
displayed, it would not be as the sender had intended (no blank line
between paragraphs):
--cut--
Content-Transfer-Encoding: 7bit
<pre>
test paragraph 1
test paragraph 2
</pre>
--703c1875a9605c5619dd34f7642dcad8--
--cut--
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=20340&edit=1