parsing long `To' and 'Cc' from email

Jonathan Gardner jgardner.jonathangardner.net at gmail.com
Thu Sep 6 16:52:34 EDT 2007


On Sep 6, 1:25 pm, Gerardo Herzig <gher... at fmed.uba.ar> wrote:
> the email.* package dont seems to parse that kind of headers
> `correctly'. What i want is to get a list with all the email address in
> the `To' header.
>
> Someone know if there is a more sofisticated parser for doing this?
>

If you're not interested in parsing the entire email message, you may
just want to run a regex on the message itself, looking for the "to"
header.

Here's a good start:

r"^to:\s*(.*)$"

You'll want to use the multi-line and case-insensitive options when
you use it.







More information about the Python-list mailing list