ID:               20340
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Closed
+Status:           Bogus
 Bug Type:         Mail related
 Operating System: Windows XP SP1
 PHP Version:      4CVS-2002-11-10
 New Comment:

The MIME-headers in the BODY of your mail are part of the BODY part,
and not of the headers. Please refer to RFC822 [1] and RFC 1341 [2]

[1] http://rfc.sunsite.dk/rfc/rfc821.html
[2] http://rfc.sunsite.dk/rfc/rfc1341.html


Previous Comments:
------------------------------------------------------------------------

[2002-11-10 19:17:29] [EMAIL PROTECTED]

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: [EMAIL PROTECTED]' . "\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('[EMAIL PROTECTED]', 'test', $body, $headers);
--cut--

------------------------------------------------------------------------

[2002-11-10 19:01:22] [EMAIL PROTECTED]

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: [EMAIL PROTECTED]' . "\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('[EMAIL PROTECTED]', '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.

------------------------------------------------------------------------

[2002-11-10 11:29:56] [EMAIL PROTECTED]

You should not put the entirety of your mail in the headers arg. Put
the headers in the headers, and the body in the body. Multiple
instances of CRLF in the headers would indicate the separation between
headers and body of the mail.

------------------------------------------------------------------------

[2002-11-10 11:10:11] [EMAIL PROTECTED]

the bug system seems to have entered an erroneous carriage return on
line 7 of my example code.

------------------------------------------------------------------------

[2002-11-10 11:04:58] [EMAIL PROTECTED]

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: [EMAIL PROTECTED]' . "\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('[EMAIL PROTECTED]', '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

Reply via email to