문제

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top