Non-deprecated equivalent of rfc822.AddressList

J

Jason Tackaberry

Hi,

Since the rfc822 module was removed in Python 3, and is deprecated in
2.3, I am obviously trying to avoid using it.

But I'm having a hard time finding an equivalent to rfc822.AddressList
in the email module, which I want to use to parse a _list_ of addresses:
[('John Doe', '(e-mail address removed)'), ('Doe, Jane', '(e-mail address removed)')]


email.utils.parseaddr() only returns the first address in the list:
('John Doe', '(e-mail address removed)')


email.utils.getaddresses() expects a list or tuple, and I can't simply
pass it addrlist.split(', ') for obvious reasons, and anyway rather
defeats the purpose of using a helper function to handle the tricky
bits.

Now, email._parseaddr.AddrlistClass has this functionality:
[('John Doe', '(e-mail address removed)'), ('Doe, Jane', '(e-mail address removed)')]

But that's obviously not a documented, public interface. Amusingly,
even in 3.1, the code for AddrlistClass says:

Note: this class interface is deprecated and may be removed in
the future. Use rfc822.AddressList instead.


Is there some non-deprecated method I can use to parse an RFC 2822
address list?

Thanks,
Jason.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,829
Messages
2,569,737
Members
45,522
Latest member
CCPAnne66

Latest Threads

Top