R. David Murray <[email protected]> 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
<[email protected]>').
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
<[email protected]>\r\n\r\n', policy=default)
>>> m['from']
'someone <[email protected]>'
>>> 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
'[email protected]'
----------
resolution: -> not a bug
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue32058>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com