This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: SMTP email policy does not encode non-ASCII characters
Type: behavior Stage:
Components: email Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: aepsil0n, barry, r.david.murray
Priority: normal Keywords:

Created on 2020-04-02 13:52 by aepsil0n, last changed 2022-04-11 14:59 by admin.

Files
File name Uploaded Description Edit
minimal.py aepsil0n, 2020-04-02 13:52
Messages (1)
msg365596 - (view) Author: Eduard Bopp (aepsil0n) * Date: 2020-04-02 13:52
Using email.policy.SMTP a message's non-ASCII characters are not encoded. The policy.utf8 attribute is set to False as documented.

The attached script illustrates the behaviour. I get the following command line output from it:

Subject: =?utf-8?b?w7zDtsOk?=


False
Subject: üöä


True
Subject: üöä


The default compat32 policy encodes the string, but the SMTP policy does not encode it, but leaves it as UTF-8 despite policy.utf8 == False. I might be misreading the documentation here, but it seems to me like utf8 == False implies that encoding should happen.
History
Date User Action Args
2022-04-11 14:59:28adminsetgithub: 84338
2020-04-02 13:52:09aepsil0ncreate