Hello !
Used with simplenews.
When a specify a "from name" with accent (éèà) it is passed throught mime_header_encode. But then I always get a displayed "from name" formated with "=?UTF-8?B?Ij0/ ......"
When I dont use accent, it's working as expected.
Disabling the mime_header_encode generate a "no sender detected" by gmail, but thunder read it correctly.

Complete from header is : (seems to be encoded several time .. no ?)

From: =?UTF-8?B?Ij0/VVRGLTg/Qj9RblZ5WldGMUlHUjFJR1REcVd6RHFXZDF3NmtndzZBZ2JHRWc=?=
=?UTF-8?B?UjJWdXc2aDJaU0JwYm5SbGNtNWhkR2x2Ym1FPT89CiA9P1VURi04P0I/YkdVZz8=?=
=?UTF-8?B?PSIgPGluZm8uZ2VuZXZlLmludGVybmF0aW9uYWxlQGV0YXQuZ2UuY2g+?=

Any hints welcome ..
Marc

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sgabe’s picture

Status: Active » Needs review

Simplenews encodes the name, later Mime Mail also encodes the header values, so they can be encoded twice.

$formatted_address = drupal_substr(PHP_OS, 0, 3) == 'WIN' ? $address : '"' . mime_header_encode($name) . '" <' . $address . '>'; 

Since Mime Mail and drupal_mail_send() will take care of this, I think it would be better to remove the mime_header_encode() call from Simplenews.

Please try to remove the function call and see if that works, if it does, I think we can move this issue to Simplenews.

$formatted_address = drupal_substr(PHP_OS, 0, 3) == 'WIN' ? $address : '"' . $name . '" <' . $address . '>'; 
Berdir’s picture

Status: Needs review » Closed (duplicate)

Ah, exactly the information I was looking for (that core does encode headers too), will be fixed in #1387648: Sender name is MIME-encoded twice.

caktux’s picture

Title: From: =?UTF-8?B?Ij0/VVRGLTg/Qj9RblZ5WldGMUlHUjF » From: in headers not properly encoded

With Simplenews not encoding the sender name, the whole From header gets encoded if Mime Mail receives a string, making it look like it was encoded twice...

maximpodorov’s picture

I confirm this problem with Cyrillic letters in From: header.

drikc’s picture

Status: Closed (duplicate) » Needs review
FileSize
909 bytes

I have tried to make an exception for the 'from' and 'sender' header property so that they use the method shown in the example for the mb_encode_mimeheader() function: http://php.net/manual/fr/function.mb-encode-mimeheader.php

xalexas’s picture

This is also a problem in 7.x-1.x-dev.
From field looks like this:
=?UTF-8?B?IlNraWphbGnFoXRhIFNyYmlqZSIgPG1hcmtldGluZ0Bza2lqYWxpc3Rhc3JiaWo=?=.=?UTF-8?B?ZS5ycz4=?=@nhpbox11.eunet.rs <=?UTF-8?B?IlNraWphbGnFoXRhIFNyYmlqZSIgPG1hcmtldGluZ0Bza2lqYWxpc3Rhc3JiaWo=?=.=?UTF-8?B?ZS5ycz4=?=@nhpbox11.eunet.rs>

sgabe’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
FileSize
569 bytes

What if we just check if the header is already MIME-encoded? The attached patch is against D7.

sgabe’s picture

Status: Needs review » Needs work

Thought the previous patch is wrong (there will be no newline character at the end), I am still wondering how this can happen when mime_header_encode() will only encode strings that contain non-ASCII characters...

    if (preg_match('/\=\?UTF-8\?B\?.*\?\=/', $value) == FALSE) {
      $headers[$key] = mime_header_encode($value);
    }
Devin Carlson’s picture

Status: Needs work » Closed (duplicate)

I recently ran into this issue and found out that it is a duplicate of #84883: Unicode::mimeHeaderEncode() doesn't correctly follow RFC 2047.