EmailMessage and RFC 2047
Peter J. Holzer
hjp-python at hjp.at
Tue Apr 30 07:11:38 EDT 2019
| This module is part of the legacy (Compat32) email API. In the current
| API encoding and decoding of headers is handled transparently by the
| dictionary-like API of the EmailMessage class.
I understood this to mean that an EmailMessage does decode RFC 2047
encoded header fields automatically.
However this does not seem to be the case:
portia:~/tmp 13:06 :-) 16% python3
Python 3.7.2+ (default, Feb 27 2019, 15:41:59)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import email.parser
>>> import email.message
>>> p = email.parser.Parser(email.message.EmailMessage)
>>> f = open("test.msg", "r")
>>> m = p.parse(f)
<email.message.EmailMessage object at 0x7f3b5cac4278>
'Martin =?iso-8859-15?Q?W=FCrtele?= <martin at xxxxxxxx.xxx>'
Am I using it wrong or did I misunderstand what is meant by "handled
transparently by the dictionary-like API of the EmailMessage class"? If
the latter, what does it mean?
_ | Peter J. Holzer | we build much bigger, better disasters now
|_|_) | | because we have much more sophisticated
| | | hjp at hjp.at | management tools.
__/ | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 833 bytes
Desc: not available
More information about the Python-list