Unfortunately the MIME package's use of Multipart/Alternative for the content type results in an unreadable message (due to an unknown content-type).
With D6 core and an html message delivered with both HTML and plain text, the Content-Type header starts out as
Content-Type: multipart/alternative;\nboundary="=_0828cbc3f5cb213da94e02f967b1c7f4"
However, Drupal's drupal_mail_send() does this to it:
$mimeheaders = array();
foreach ($message['headers'] as $name => $value) {
$mimeheaders[] = $name .': '. mime_header_encode($value);
}
resulting in a header like this:
Content-Type: =?UTF-8?B?bXVsdGlwYXJ0L2FsdGVybmF0aXZlOwogYm91bmRhcnk9Ij1fZGNmMTFmZmZmMzc=?=
=?UTF-8?B?MjRjYjYwZDMyZWQ0MGQyMGI3NDE2Ig==?=
Which ends up being a mimetype which no mail client can understand, so you have an email that looks like this:
The attached patch attempts to undo this damage by just removing the \n for a far more normal Content-Type header. This is kind of hacky, but without changing PEAR's Mail/Mime.php I don't know what would be a reasonable alternative.
Comment | File | Size | Author |
---|---|---|---|
#1 | rfay_screenshot 2012-10-15 at 12.46.10 PM.png | 19.81 KB | rfay |
mailmime.fix_bad_content_type_header.patch | 664 bytes | rfay |
Comments
Comment #1
rfayWhat email looks like without this patch:
Comment #2
salvisIs this D6-only or does it apply to D7 as well?
Comment #3
salvisI would really like to create new releases for Mail MIME, but we have three patches in the queue that should probably be committed:
#1813542: Multipart/Alternative with line break (introduced by PEAR) breaks drupal core and results in unreadable message (D6 — what about D7???)
#1929678: Mail MIME inline images using image_style's do not work with Drupal 7.20 (D7, maybe D6, too)
#1935610: url_to_realpath fix (D7, maybe D6, too)
I'm not using Mail MIME myself, and I need someone to review these patches. Maybe the three authors could trade reviews? Or someone else who is actively using Mail MIME?
Comment #4
DuaelFrThis patch applies on D7 but seems not needed as the described behavior does not happens on a vanilla install.
Comment #5
salvisCommitted to 6.x-2.x-dev.
Thank you for unblocking us, DuaelFr!
Comment #6.0
(not verified) CreditAttribution: commentedUpdated issue summary.