I create an e-mail message, and I just want to get the From
header field back as I supplied it (as the documentation says:
"__getitem__(name) Return the value of the named header field."),
but when the header field is "
[email protected] (Name)", I just
get "
[email protected]" instead of "
[email protected] (Name)"
(see code example below).
How can I get the value of the named header field "From",
as the documentation says?
main.py
import email
import email.policy
posting = email.message_from_bytes\
( b'From: Name <
[email protected]>\r\n', policy=email.policy.default )
print( posting[ 'From' ])
posting = email.message_from_bytes\
( b'From:
[email protected] (Name)\r\n', policy=email.policy.default )
print( posting[ 'From' ])
output (as is)
Name <
[email protected]>
[email protected]
output (as wanted)
Name <
[email protected]>
[email protected] (Name)
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)