|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-11-10 11:04 UTC] _ at mrmachine dot 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--
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 23:00:01 2025 UTC |
this bug is not bogus, and it is not invalid to put content inside the headers. in fact, it is required for example when attaching a file. see my extended code example which does as you suggest, with identical results (no body or attachment shows up in outlook express). --cut-- $headers = 'From: tai_lee@mrmachine.net' . "\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-Type: multipart/mixed;' . "\r\n"; $headers .= ' boundary="74233bf674edd3ebd68da956062cd872"' . "\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 .= '--68a7876fa15399a2f9ea92cf7571bdd6' . "\r\n"; $headers .= 'Content-Type: image/gif;' . "\r\n"; $headers .= ' name="arrows.gif"' . "\r\n"; $headers .= 'Content-Transfer-Encoding: base64' . "\r\n"; $headers .= 'Content-Disposition: attachment;' . "\r\n"; $headers .= ' filename="arrows.gif"' . "\r\n\r\n"; $headers .= 'R0lGODlhCwAHAMQVAAEBAfz//QAABAIAAQEBAP/+/AABBQEBA/7+/gIAA//9/gACAQEAAv///f7/' . "\r\n"; $headers .= '///+/wAAAgEAAAABAP///wAAAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEA' . "\r\n"; $headers .= 'ABUALAAAAAALAAcAAAU6YMRQUkJKUFVRgRQhS/IIaTQ9S+NQT+OSDoVEMSEgCgOKYyKZTHiOg6sR' . "\r\n"; $headers .= 'oUwgPGzFwABAIhIKJVUJAQA7' . "\r\n\r\n"; $headers .= '--68a7876fa15399a2f9ea92cf7571bdd6--' . "\r\n"; $body = '<pre>' . "\r\n"; $body .= 'test paragraph 1' . "\r\n\r\n"; $body .= 'test paragraph 2' . "\r\n"; $body .= '</pre>' . "\r\n\r\n"; mail('_@mrmachine.net', 'test', $body, $headers); --cut-- also if i were not to use $headers for actual content, how could i specify a text version and an html version of the email? there is no reason not to allow people to create an entire (valid) mime format email and send it through the headers.i tried putting all headers that contain content into the $body, and that seems to fool it. i still believe however, that headers should not be manipulated in that way. it's a hack to have to put half your mime headers in the body and half in the headers. --cut-- $headers = 'From: _@mrmachine.net' . "\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-Type: multipart/mixed;' . "\r\n"; $headers .= ' boundary="a646837d88fd9ce72caf49ee0efa4c0e"' . "\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"; $body = '--a646837d88fd9ce72caf49ee0efa4c0e' . "\r\n"; $body .= 'Content-Type: text/html;' . "\r\n"; $body .= ' charset="iso-8859-1"' . "\r\n"; $body .= 'Content-Transfer-Encoding: 7bit' . "\r\n\r\n"; $body .= 'test' . "\r\n\r\n"; $body .= '--a646837d88fd9ce72caf49ee0efa4c0e' . "\r\n"; $body .= 'Content-Type: image/gif;' . "\r\n"; $body .= ' name="arrows.gif"' . "\r\n"; $body .= 'Content-Transfer-Encoding: base64' . "\r\n"; $body .= 'Content-Disposition: attachment;' . "\r\n"; $body .= ' filename="arrows.gif"' . "\r\n\r\n"; $body .= 'R0lGODlhCwAHAMQVAAEBAfz//QAABAIAAQEBAP/+/AABBQEBA/7+/gIAA//9/gACAQEAAv///f7/' . "\r\n"; $body .= '///+/wAAAgEAAAABAP///wAAAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEA' . "\r\n"; $body .= 'ABUALAAAAAALAAcAAAU6YMRQUkJKUFVRgRQhS/IIaTQ9S+NQT+OSDoVEMSEgCgOKYyKZTHiOg6sR' . "\r\n"; $body .= 'oUwgPGzFwABAIhIKJVUJAQA7' . "\r\n\r\n"; $body .= '--a646837d88fd9ce72caf49ee0efa4c0e--' . "\r\n"; mail('_@mrmachine.net', 'test', $body, $headers); --cut--