-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Wrong charset handling in MailSender #5096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hello, i am new here and i would like to try and fix this bug. Can you please give me some guidlines and tell me how to recreate this issue? |
Sure, you can go ahead. |
The documentation about using the |
Hello, I have made a small change and now when you send an email with utf-8 encoding the body of the email looks fine and does not have a base64 encoding. 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. |
I created a pull request and I am looking forward for your feedback. Thank you!! @Gallaecio @wRAR |
Changes: Implemenetation - Set encoding utf-8 for payload inside send - Refactor code Testing - Test body in payload encoded in utf-8
Looks like passing
charset='utf-8'
makes a plain text message withContent-Transfer-Encoding: base64
which then can't be read.At
scrapy/scrapy/mail.py
Line 81 in 5a75b14
set_charset
is called but as the payload is not set yet, the underlying class just sets the headers. When laterset_payload
is called, it doesn't do any encoding, but theContent-Transfer-Encoding
is already set. Looks like the fix should be passing the encoding toset_payload
too, like was proposed in #3722 (andset_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.
The text was updated successfully, but these errors were encountered: