I have the plain text of a Cc header field that looks like so:
[email protected], John Smith <[email protected]>,"Smith, Jane" <[email protected]>
Are there any battle tested modules for parsing this properly?
(bonus if it's in python! the email module just returns the raw text without any methods for splitting it, AFAIK) (also bonus if it splits name and address into to fields)
There are a bunch of function available as a standard python module, but I think you're looking for email.utils.parseaddr() or email.utils.getaddresses()
>>> addresses = '[email protected], John Smith <[email protected]>,"Smith, Jane" <[email protected]>'
>>> email.utils.getaddresses([addresses])
[('', '[email protected]'), ('John Smith', '[email protected]'), ('Smith, Jane', '[email protected]')]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With