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
smtplib.send_message mishandles 8BITMIME RFC 6152 #76995
Comments
According to https://tools.ietf.org/html/rfc6152 you should only send an 8bit email body when the server advertises 8BITMIME in the EHLO, and you should declare it with BODY=8BITMIME in the MAIL command. The default cte_type is 8bit for the new default email policy which is what will be used by smtplib.send_message when it calls BytesGenerator.flatten, but it will not set BODY=8BITMIME even if the message has any 8-bit characters. It will only set BODY=8BITMIME if the message uses any utf-8 mail/from addresses. This means that a message with ASCII addresses and an 8-bit utf-8 body will be sent without BODY=8BITMIME (I think that's actually quite common). What should be done is checking if the server advertises 8BITMIME, and if it doesn't use cte_type=7bit; if it does we should set BODY=8BITMIME if the policy is using cte_type=8bit. I don't know whether any real email server chokes on this. But it's best to follow the RFC, I think. |
I agree. I'll be happy to review a patch proposal. Not sure how I overlooked this when I implemented send_message, but that was early enough in my reading of all the RFC that I may have just missed that detail :( |
OK, the bpo-32663 test fix I mentioned in the review is merged. |
Yeah. I already merged it in. |
Merged into the PR that is. |
This is just to note that I'm investigating this as part of the CPython sprint in EuroPython. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: