Hello,
Using non-ascii caracters in the "From:" field should be encoded (with mime_header_encode?) in order to be read correctly by non-UTF8 readers and to not get stopped by spam-filters.
For example: "From: Étienne Foo" needs to be "From: =utf8?...tienne Foo".
Same problem with cyrillic or other alphabets.
I have made the following changes to mimemail.module in order to solve the problem. Can you confirm if it is correct?
function mimemail_address($address) {
if (is_array($address)) {
// it's an array containing 'mail' and/or 'name'
if (isset($address['mail'])) {
$output = '';
if (empty($address['name'])) {
return $address['mail'];
} else {
return '"'.addslashes(mime_header_encode($address['name'])).'" <'.$address['mail'].'>'; // [ML]
}
}
// it's an array of address items
$addresses = array();
foreach($address as $a) {
$addresses[] = mimemail_address($a);
}
return $addresses;
}
// it's a user object
if (is_object($address) && isset($address->mail)) {
return '"'.addslashes(mime_header_encode($address->name)).'" <'.$address->mail.'>'; // [ML]
}
// it's formatted or unformatted string
// TODO shouldn't assume it's valid - should try to re-parse
if (is_string($address)) {
return $address;
}
// it's null. return the site default address
if (is_null($address)) {
return array(
'name' => mime_header_encode(variable_get('site_name', 'Drupal')), // [ML]
'mail' => variable_get('site_mail', ini_get('sendmail_from')),
);
}
return false;
}
Patch included in attachment. (the patch is made on the HEAD, but I am using 1.x)
Thanks,
Mathieu Lutfy
Réseau Koumbit
| Comment | File | Size | Author |
|---|---|---|---|
| mimemail.module.patch | 1.36 KB | bgm |
Comments
Comment #1
jerdavisI'll test this and report back, looks good though.
Comment #2
jerdavisCommited this to HEAD with the inclusion of a mime_header_encode() call within mimemail_headers().
Thanks!
Comment #3
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.