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.

Author _savage
Recipients _savage, barry, maciej.szulik, python-dev, r.david.murray
Date 2018-07-31.12:21:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1533039702.83.0.56676864532.issue24218@psf.upfronthosting.co.za>
In-reply-to
Content
I was about to open an issue when I found this one.

Consider an email message with the following:

message = EmailMessage()
message["From"] = Address(addr_spec="bar@foo.com", display_name="Jens Troeger")
message["To"] = Address(addr_spec="foo@bar.com", display_name="Martín Córdoba")

It’s important here that the email itself is `ascii` encodable, but the names are not. With that combination, send_message() falsely assumes plain text addresses (see https://github.com/python/cpython/blob/master/Lib/smtplib.py#L949 where it checks only email addresses, not display names!) and therefore the `international` flag stays False.

As a result of that, flattening the email object (https://github.com/python/cpython/blob/master/Lib/smtplib.py#L964) incorrectly inserts multiple linefeeds, thus breaking the email header, thus mangling the entire email:

flatmsg: b'From: Jens Troeger <jens@talaera.com>\r\nTo: Fernando =?utf-8?q?Mart=C3=ADn_C=C3=B3rdoba?= <foo@bar.com>\r\r\r\r\r\nSubject:\r\n Confirmation: …\r\n…'

I think a proper fix would be in line 949, where email addresses and display names should be checked for encoding.

The comment to that function should also be adjusted to mention display names?

Note also that the attached patch does not test the above scenario, and should probably be extended as well.
History
Date User Action Args
2018-07-31 12:21:42_savagesetrecipients: + _savage, barry, r.david.murray, python-dev, maciej.szulik
2018-07-31 12:21:42_savagesetmessageid: <1533039702.83.0.56676864532.issue24218@psf.upfronthosting.co.za>
2018-07-31 12:21:42_savagelinkissue24218 messages
2018-07-31 12:21:42_savagecreate