开发者

Is there a non-deprecated equivalent of rfc822.AddressList?

开发者 https://www.devze.com 2023-01-23 00:53 出处:网络
I need something like rfc822.AddressList to parse, say, the content of the \"TO\" header field of an email into individual addresses.Since rfc822 is deprecated in favor of the email package, I looked

I need something like rfc822.AddressList to parse, say, the content of the "TO" header field of an email into individual addresses. Since rfc822 is deprecated in favor of the email package, I looked for something similar there but couldn't find anything. Does anyone know what I开发者_运维百科'm supposed to use instead?

Thanks!


Oh it's email.utils.getaddresses. Just make sure to call it with a list.


If you are open to using a third party module, I ported the Python 2.x module rfc822 to Python 3.x

https://github.com/MarkNenadov/rfc822py3

It hasn't been tested thoroughly yet. I encourage you to try it out and let me know how it works and whether you have any problems.

To make your code work in both Python 2 and 3 you can take my rfc822py3 module and do:

try:
   import rfc822
except ImportError:
   import rfc822py3 as rfc822
0

精彩评论

暂无评论...
验证码 换一张
取 消