Similar to the http://drupal.org/node/1182360 issue.
The $sender variable in headers is double encoded.
In the function mimemail_headers()
// Convert From header if it is an array.
if (is_array($headers['From'])) {
$headers['From'] = mimemail_address($headers['From']);
}
// Run all headers through mime_header_encode() to convert non-ascii
// characters to an rfc compliant string, similar to drupal_mail().
foreach ($headers as $key => $value) {
$headers[$key] = mime_header_encode($value);
}
And before in mimemail_address() function:
if (is_array($address)) {
// It's an array containing mail and/or name.
if (isset($address['mail'])) {
$output = '';
if (empty($address['name']) || $simple_address) {
return $address['mail'];
}
else {
return '"'. addslashes(mime_header_encode($address['name'])) .'" <'. $address['mail'] .'>';
}
}
// It's an array of address items.
$addresses = array();
foreach ($address as $a) {
$addresses[] = mimemail_address($a);
}
return $addresses;
}
When address field is array and contains unicode chanracter, 'From' header looks like "=?UTF-8?B?Ij0/VVRGLTg/Qj9VbVZ1ZEdsdVowbHVkR1Z5Ym1GMGFXOXVZV3d1WTI5dElGUm8=?=.=?...."
Comments
Comment #1
jvieille commented(updated)
I propose to solve it this way :
In mimemail.inc, function mimemail_headers()
Comment #2
harryster commentedThanks, #1 this works. Such a basic issue, I wonder how it slipped through!
Comment #3
zionduc commentedI had the same problem with 7.x-1.0-beta3 version too but #1 solve it for me too.
Here is the patch for 6.x-1.x-dev
Comment #4
zionduc commentedAnd here is the patch for 7.x-1.x-dev
Comment #5
sgabe commentedWe may also remove the
mime_header_encode()call inmimemail_address(). Let me know if this works for you.Comment #6
sgabe commented@bisonbleu, please test again the attached patch in #5, that should be the solution. Note that you must clear the cache. Just to be sure would be better to create a new rule for testing.
Comment #7
bisonbleu commentedI should apply patch in #5 ALONE i.e. without patch #4?
Thanks for helping me through @sgabe!
Comment #8
sgabe commented@bisonbleu, you understood me correctly, just alone the patch in #5 should be enough to solve the problem, since mimemail_address() is the one that gets called multiple times.
Comment #9
bisonbleu commentedI just tested patch #5 on its own (without patch #4) on a fresh mimemail-7.x-1.0-beta3 and it doesn't fix this issue. I did clear the caches after the patch was applied (drush cc all). Here's what I see in the Mail delivery failed message.
Tested patch #5 on a fresh mimemail-7.x-1.x-dev and it also doesn't work. I cleared the caches after applying the patch. Here's what I see in the Mail delivery failed message.
Reverting to mimemail-7.x-1.0-beta3 + patch #4 because it works.
Comment #10
sgabe commentedThat is strange since with the patch in #5 the From header is correctly encoded only once. There has to be another issue. I guess your working test messages contain From\Sender field without encoding.?
Comment #11
bisonbleu commentedCorrect me if I'm wrong but in #9, the From header is double encoded in both cases. It looks like this (note the absence of any email)
while it looks as follows when it is successful:
Comment #13
sgabe commentedWhat you are seeing is that mimemail_address() only encodes the name while mimemail_headers() encodes both the name and the address in one step.
According to RFC 2047 the problem is that the address cannot be encoded:
Patch in #4 is committed, thanks everyone!