There is an error with character encoding in sender name. I got this as sender name,

MNM RC3A9gC3A9szeti AdatbC3A1zis

but it's not correct. Here is the right one,

MNM Régészeti Adatbázis

.

http://www.fileformat.info/info/unicode/char/00e9/index.htm

I attached a screenshot as well.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

asrob created an issue. See original summary.

Ramdas Gaikar’s picture

I can see the default encoding set in PHPMailer.php file is as below :

/**
* Sets the Encoding of the message. Options for this are
* "8bit", "7bit", "binary", "base64", and "quoted-printable".
* @var string
*/
public $Encoding = '8bit';

Also I can see the below function does the Encoding of Header including From Name.

public function EncodeHeader($str, $position = 'text');

So someone who can dig little more, will get the issue.

artem0793’s picture

Assigned: Unassigned » artem0793
asermc’s picture

Hi!
Do you have a way or idea to resolve this problem?

thanks a lot

jjcarrion’s picture

I have the same problem with Swedish characters, but I have it in the subject as well.

I have tried different things:

hook_mail_alter:

function mymodule_mail_alter(&$message) {
  $message['subject'] = substr(iconv_mime_encode("", $message['subject']), 2);
  $message['headers']['From'] = substr(iconv_mime_encode("", $message['headers']['From']), 2);
}

With this, the subject was fixed but I couldn't change the From at all.

Changing the CharSet in PHPMailer

I did something like $mailer->CharSet = 'utf-8'; but it didn't work.

So, finally I did what I have in the patch and that solved my problem but I don't think that this is a general solution.

If we could change the PHPMailer Charset, maybe we could create a setting for that so the user could set the CharSet that they need for their project. Any ideas on this?

petergus’s picture

I ended up using the patch at https://www.drupal.org/node/2865880 because this didn't really work, especially for the Reply-to name.

Did you find any other solution yet?

recidive’s picture

Attached is a patch that uses the Unicode::mimeHeaderEncode() instead of iconv_mime_encode(). And apply the encoding to From, ReplyTo, CC, BCC and Subject.

artem0793’s picture

Assigned: artem0793 » Unassigned
swentel’s picture

The Unicode::mimeHeaderEncode() seems logical, especially since PhpMail does this as well!

hanness’s picture

Status: Needs review » Reviewed & tested by the community

#7 worked fine for us. tested with subject and from.

C-Logemann’s picture

Successfully tested patch #7 and added to patch management of two productive websites. So +1 for RTBC

keopx’s picture

+1 for RTBC

fall_0ut’s picture

Tested with patch #7, works fine

Ismail Cherri’s picture

Test patch #7 and it is working fine.

mgstables’s picture

Tested patch #7 and it is working

wundo’s picture

  • wundo committed 5a62cc9 on 8.x-1.x authored by recidive
    Issue #2755027 by recidive, jjcarrion, asrob, wundo: Wrong character...
  • wundo committed c1e6a2d on 8.x-1.x
    Issue #2755027: ordering dependencies
    
wundo’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.