Wrong charset handling in MailSender
See original GitHub issueLooks like passing charset='utf-8'
makes a plain text message with Content-Transfer-Encoding: base64
which then can’t be read.
At https://github.com/scrapy/scrapy/blob/5a75b14a5fbbbd37c14aa7317761655ac7706b70/scrapy/mail.py#L81 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:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top 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 mail.py. 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 - AspEmail.com
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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That would be great! Feel free to make it a regular pull request if it’s ready for review and discussion.
The documentation about using the
MailSender
class is at https://docs.scrapy.org/en/latest/topics/email.html . 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.