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: RFC 6531 (SMTPUTF8) support in smtplib
Type: enhancement Stage: resolved
Components: email Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: barry, jesstess, maciej.szulik, pitrou, python-dev, r.david.murray, zvyn
Priority: normal Keywords: patch

Created on 2014-07-21 21:29 by zvyn, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
smtplib_smtputf8_issue21725-dependent.patch zvyn, 2014-07-21 21:28 review
smtplib_smtputf8_issue21725-dependentV2.patch zvyn, 2014-08-09 00:00 fixed warnings; adjusted Doc according to berkerpeksag's comment review
smtplib_smtputf8V3.patch zvyn, 2014-08-11 23:03 review
smtplib_smtputf8v4.patch r.david.murray, 2015-05-14 02:50 review
Messages (5)
msg223610 - (view) Author: Milan Oberkirch (zvyn) * Date: 2014-07-21 21:28
This patch is related to and depends on issue 21725. I put it here for review, it can be applied (maybe with small changes) as soon as issue 21725 is fixed.
msg225207 - (view) Author: Milan Oberkirch (zvyn) * Date: 2014-08-11 23:03
After blindly raising errors for 'SMTPUTF8' without 'BODY=.*' I found out that 'SMTPUTF8' alone is actually perfectly fine (for using international names in addresses but sending ASCII data). Which means I did a mistake in the smtpd patch :(
The attached 3rd version of the smtplib patch implements your suggestions, including re-factoring of the mail option parsing. One test is commented out until smtpd is fixed. I'll do that as -part of- issue 21795 tomorrow.
msg243147 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-05-14 02:50
Coming back to this, I noticed a number of things wrong with the logic that I'm not sure how I missed before.  I had to rewrite pretty much all of the logic.  The good news is the patch is now smaller :)

The new tests are failing, because they are wrong: the msg argument to sendmail/mail *must* be a byte string if smtputf8 is in effect, since an email message may contain multiple encodings as well as other binary data.  (Well, the msg argument could be an ascii string, but what would be the point?)

I'm uploading this without fixing the tests because I'm out of time for now and may not get back to it before the weekend.  Perhaps someone else will have time to work on the tests before then.
msg243344 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-05-16 17:58
New changeset 6b0e4c87bf9e by R David Murray in branch 'default':
#22027: Add RFC6531 support to smtplib.
https://hg.python.org/cpython/rev/6b0e4c87bf9e
msg243346 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-05-16 18:05
Rewrote the tests to keep all the existing tests working against an unmodified SimSMTPServer, so that we know backward compatibility is maintained.  And as I said, I changed the tests to reflect that a non-ascii body must be provided as binary data, which means I deleted two tests.

(Note: in thinking about this, I vaguely remember some conversations where we thought it might make sense that if someone provided a message string that when encoded to utf-8 then conforms to the RFC, it would be OK to auto-encode it as utf-8, but I'm just not comfortable with that idea.  It provides insufficient value compared to the danger of blindly encoding something that is not RFC conformant...if someone does build a such a unicode message, they should have to convert it themselves before passing it to smtplib, as a sign they know what they are doing :)

Thanks for your work Milan.
History
Date User Action Args
2022-04-11 14:58:06adminsetgithub: 66226
2015-05-16 19:51:23r.david.murraylinkissue8489 superseder
2015-05-16 18:05:28r.david.murraysetstatus: open -> closed
resolution: fixed
messages: + msg243346

stage: resolved
2015-05-16 17:58:31python-devsetnosy: + python-dev
messages: + msg243344
2015-05-14 02:50:39r.david.murraysetfiles: + smtplib_smtputf8v4.patch
nosy: + maciej.szulik
messages: + msg243147

2014-08-11 23:03:06zvynsetfiles: + smtplib_smtputf8V3.patch

messages: + msg225207
2014-08-09 00:00:17zvynsetfiles: + smtplib_smtputf8_issue21725-dependentV2.patch
2014-08-06 21:57:30zvynsetfiles: - smtpd_remove_deprecated_attrs_v2.patch
2014-07-29 23:33:26zvynsetfiles: + smtpd_remove_deprecated_attrs_v2.patch
2014-07-21 21:29:00zvyncreate