[New-bugs-announce] [issue40157] SMTP email policy does not encode non-ASCII characters

Eduard Bopp report at bugs.python.org
Thu Apr 2 09:52:09 EDT 2020


New submission from Eduard Bopp <eduard.bopp at aepsil0n.de>:

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.

----------
components: email
files: minimal.py
messages: 365596
nosy: aepsil0n, barry, r.david.murray
priority: normal
severity: normal
status: open
title: SMTP email policy does not encode non-ASCII characters
type: behavior
versions: Python 3.6, Python 3.7, Python 3.8
Added file: https://bugs.python.org/file49026/minimal.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40157>
_______________________________________


More information about the New-bugs-announce mailing list