Question

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!

Was it helpful?

Solution

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

OTHER TIPS

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top