drupal_html_to_text inserts LF in subject causing outgoing e-mail to fail
Ken Knowles - April 19, 2009 - 05:17
| Project: | Mime Mail |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
The encoding of the subject includes a call to drupal_html_to_text. This function is probably not necessary for the subject line since any HTML in the subject line would not be rendered (that I know of). Although it shouldn't cause a problem with the encoding, drupal_html_to_text occasionally inserts a linefeed. This corrupts the subject line and causes the call to the PHP mail function to fail.
Attached is a patch to eliminate the call to drupal_html_to_text for the subject only.
| Attachment | Size |
|---|---|
| Patch to remove call to drupal_html_to_text | 673 bytes |

#1
Using Notifications module with mime mail, SpamAssasin was telling me that : "1.5 SUBJECT_ENCODED_TWICE Subject: MIME encoded twice"
Subject: =?UTF-8?B?dGVzdC5pbnRlcmZpbmFuY2Uub3JnIHN1YnNjcmlwdGlvbiB1cGRhdGUgZm9yIG0=?= =?UTF-8?B?aWNoZWxAaGRnLmJlCg==?=
After patching:
function mime_header_encode($string) {return $string; // added for test
if (preg_match('/[^\x20-\x7E]/', $string)) {
$chunk_size = 47; // floor((75 - strlen("=?UTF-8?B??=")) * 0.75);
$len = strlen($string);
$output = '';
while ($len > 0) {
$chunk = drupal_truncate_bytes($string, $chunk_size);
$output .= ' =?UTF-8?B?'. base64_encode($chunk) ."?=\n";
$c = strlen($chunk);
$string = substr($string, $c);
$len -= $c;
}
return trim($output);
}
return $string;
}
I got:
Subject: =?UTF-8?B?Tm90aWZpY2F0aW9ucyBkaWdlc3QK?=
Then I revert the change in mime_header_encode and applying the patch (eliminate the call to drupal_html_to_text for the subject only)
I got a correct result:
Subject: Notifications digest
Conclusion: correct solution, no false spam anymore.
Michel
#2
We've noticed this too. We are using phpmailer as well, and outlook users are seeing a square char at the end of each subject line.
Will test this and report back.
#3
Patch works. After patching the subject looks good in outlook.
#4
+1 on this bugfix. It removes the weird little square.
Actually, some versions of Outlook behave even worse; they think that the email body starts after that linefeed. So when the user opens his mail, all he sees is the raw message contents, starting with the header following "Subject:".
I see similar behaviour in mutt, only less extreme; it shows one or two headers (To and Date) as text contents of the mail, but it still shows the different mime parts as different attachments.
I didn't get the error described by the OP, though. Perhaps that depends on the particular MTA used?
It would be great if this patch could be integrated in the next release of MimeMail.
#5
+1 on this, we're seeing this issue too.
#6
+ 1 from me too. Thanks
#7
This has been fixed by http://drupal.org/cvs?commit=214382 a while ago.
#8
Automatically closed -- issue fixed for 2 weeks with no activity.