Home » Mail » Mail » Bug #8688
Multiple-line-Header values breakup
Details
| Submitted | 2006-09-14 07:38 UTC |
|---|---|
| From | BBrunekreeft at gmail dot com |
| Assigned | jon |
| Status | Closed |
| Package | |
| PHP Version | 5.0.4 |
| OS | Linux |
| Roadmaps | (Not assigned) |
Comments
[2006-09-14 07:38 UTC] BBrunekreeft at gmail dot com
Description:
------------
Header values that contain mulitple lines got broken.
Might have something to do with the function _sanitizeHeaders()
Test script:
---------------
<?php
include('Mail.php');
include('Mail/mime.php');
$text = 'Text version of email';
$html = '<html><body>HTML version of email</body></html>';
$file = '/home/richard/example.php';
$crlf = "\n";
$hdrs = array(
'From' => 'you@yourdomain.com',
'Subject' => 'Test mime message'
);
$mime = new Mail_mime($crlf);
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
$mime->addAttachment($file, 'text/plain');
$body = $mime->get();
$hdrs = $mime->headers($hdrs);
$mail =& Mail::factory('mail');
$mail->send('postmaster@localhost', $hdrs, $body);
?>
Expected result:
----------------
These mailheaders:
From: <you@yourdomain.com>
Content-Type: multipart/alternative;
boundary="=_de6eb08485583393f6b58691fe6d64ba"
Message-Id: <20060914072502.5ED9CA64001@yourdomain.com>
Actual result:
--------------
These headers. Note that the second part of the content-type is missing
From: <you@yourdomain.com>
Content-Type: multipart/alternative;
Message-Id: <20060914072502.5ED9CA64001@yourdomain.com>
[2006-09-14 21:03 UTC] dwarth at gmail dot com
Here is a really fast fix for those have the
Content-Type: multipart/alternative;
boundary="=_de6eb08485583393f6b58691fe6d64ba"
becoming
Content-Type: multipart/alternative;
NOTE: That fix is only as an Emergency fix (we have > 20 sites forms crashing!).
before calling
$mail->send($recipients, $headers, $body);
add:
if (isset($headers['Content-Type'])) {
$headers['Content-Type'] = preg_replace('=(<CR>|<LF>|0x0A/%0A|0x0D/%0D|\\n|\\r)(.*)=', ' $2', $headers['Content-Type']);
}
it will replace the newline character with a space and your email will be receive correctly