R. David Murray <rdmur...@bitdance.com> added the comment: parseaddr is for parsing the contents of an address header, not for parsing any additional text. So the correct way to call it is parseaddress('someone <some@email.address>').
In any case, please look in to the new email policies, which provide a much more convenient API: >>> from email import message_from_bytes >>> from email.policy import default >>> m = message_from_bytes(b'Subject: I am a bug [Random]\r\nFrom: someone <some@email.address>\r\n\r\n', policy=default) >>> m['from'] 'someone <some@email.address>' >>> m['from'].addresses (Address(display_name='someone', username='some', domain='email.address'),) >>> m['from'].addresses[0].display_name 'someone' >>> m['from'].addresses[0].username 'some' >>> m['from'].addresses[0].addr_spec 'some@email.address' ---------- resolution: -> not a bug stage: -> resolved status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32058> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com