V12: email sender name shown as "From: utf8qL..."

Dear colleagues,

just observed a strange behaviour on newly setup v12 (ERPNext 12.1.6) instances: when I send an email from an account who has special characters in its name (ä, ü, ö, …), the “From” line in the email becomes something like “From: utf8qMax MC3BCller max.mueller@example.com”.

Workaround seems to be to remove the special characters (Name: Max Mueller), than it works…

Has anyone seen this and knows how to correct it?

Thanks!

Hi @lasalesi,
I know this answer is a bit late, but I encountered the same problem and did a little bit of research. The problem can be solved if you change the following code lines in \frappe\frappe\core\doctype\communication\email.py

237      if doc.sender:
238          # combine for sending to get the format 'Jane <jane@example.com>'
239 -        doc.sender = formataddr([doc.sender_full_name, doc.sender])
239 +        doc.sender = "{0} <{1}>".format(doc.sender_full_name, doc.sender)

It seems like the sender’s name is encoded twice in the Email Queue Doctype. The sender’s email address should be something like =?utf-8?q?Michael_Wei=C3=9Fer?= <test@example.com> for a name like Michael Weißer, however it gets stripped to utf8qMichael_WeiC39Fer <test@example.com>. This causes it to be displayed incorrectly.

The above code fixes that issue, however I don’t want to open a Pull Request yet, because I don’t really understand why it fixes the problem.

Maybe someone else can help in this regard.

1 Like

Hi @P-Froggy ,

thank you so much for your answer. I will give this a try. At the moment, we have worked around it by using only User > Full names without special characters.

I guess the reason formataddr behaves differently comes from its implementation, while .format will always work with utf-8/unicode in Python 3.