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: EmailMessage incorrectly splits name and address header
Type: behavior Stage: resolved
Components: email Versions: Python 3.8
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: barry, r.david.murray, thehesiod
Priority: normal Keywords:

Created on 2021-11-29 22:10 by thehesiod, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg407329 - (view) Author: Alexander Mohr (thehesiod) * Date: 2021-11-29 22:10
If you have a reply-to list that contains a name with a comma it must be quoted, however if the line length is just right python with split the name incorrectly and not keep the quote.  Note that the CC line keeps the quote in the name but the reply-to does not, presumably since the line is slightly longer.

example:
from email.message import EmailMessage


def main():
    message = EmailMessage()
    message['From'] = 'no-reply@farmersbusinessnetwork.com'
    message['Reply-To'] = """MEGAN FOOOBAAAAAR <abcfghijkladbfrg@akdja.com>,"KDJEHGI, SCOTT KJUYT" <abcfghijkladbfrg@akdja.com>"""
    message['To'] = """"KDJEHGI, SCOTT KJUYT" <SCOTT.KDJEHGI@MYFNBBANK.COM>"""
    message['Subject'] = "does not matter"
    message['CC'] = """MEGAN FOOOBAAAAAR <abcfghijkladbfrg@akdja.com>,"KDJEHGI, SCOTT KJUYT" <abcfghijkladbfrg@akdja.com>"""
    message.set_content('foo bar')
    print(message.as_string())


if __name__ == '__main__':
    main()
msg407377 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2021-11-30 14:58
This is a duplicate of #44637.
History
Date User Action Args
2022-04-11 14:59:52adminsetgithub: 90090
2021-11-30 14:58:49r.david.murraysetstatus: open -> closed
resolution: duplicate
messages: + msg407377

stage: resolved
2021-11-29 22:32:36thehesiodsettitle: EmailMessage incorrectly splits reply-to header -> EmailMessage incorrectly splits name and address header
2021-11-29 22:10:40thehesiodcreate