Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong charset handling in MailSender

See original GitHub issue

Looks like passing charset='utf-8' makes a plain text message with Content-Transfer-Encoding: base64 which then can’t be read.

At set_charset is called but as the payload is not set yet, the underlying class just sets the headers. When later set_payload is called, it doesn’t do any encoding, but the Content-Transfer-Encoding is already set. Looks like the fix should be passing the encoding to set_payload too, like was proposed in #3722 (and set_charset may be safe to be removed, not sure about this). Note that we have tests but they don’t catch this.

Note also, that all of this seems to be compat code according to the Python docs.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

Gallaeciocommented, Apr 26, 2021

Do you want me to do a pull request or maybe a draft pull request to see what I have done and give me feedback?

That would be great! Feel free to make it a regular pull request if it’s ready for review and discussion.

Gallaeciocommented, Apr 13, 2021

Can you please give me some guidlines and tell me how to recreate this issue?

The documentation about using the MailSender class is at . Then it should be a matter of following the instructions on the issue description (“passing charset=‘utf-8’”), and verify that indeed the resulting email message cannot be read.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix charset handling in MailSender #5506 - GitHub
I created a Pull Request for wrong charset handling in Mail Sender. Encode in utf-8 th payload from send inside Remove set...
Read more >
UTF-8 charset doesn't work with javax.mail - Stack Overflow
Just call this constructor to create a MimeMessageHelper that encode UTF-8 as we escpect: MimeMessage **mimeMessage** = mailSender.createMimeMessage(); ...
Read more >
Send an email encoded in UTF-8 with javamail, character ...
The problem is that when the email is sent, the mail client (like outlook) receive it in the wrong format : uscii, 7...
Read more >
Object Reference -
Specifies the charset part of the Content-Type MIME header. Setting this property to a non-default value causes AspEmail to perform a conversion of...
Read more >
Block a mail sender - Microsoft Support
As part of its filtering criteria, the Outlook Junk Email Filter checks message senders against lists of email addresses and Internet domains designated ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found