Re: parsing long `To' and 'Cc' from email
Gerardo Herzig wrote: > Steve Holden wrote: [...] >>> >> Have you tried using email.utils.getaddresses()? >> >> regards >> Steve >> >> > No, i was not. And it works just perfect! One day i will make a hard > question!! I wonder why this getaddresess() function is not a method > into the HeaderParser class. > > Ok, so my content-filter can continue now. Thanks Steve! Don't thank me, thank Barry Warsaw - he wrote most of this code. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - -- http://mail.python.org/mailman/listinfo/python-list
Re: parsing long `To' and 'Cc' from email
Steve Holden wrote: >Gerardo Herzig wrote: > > >>Hi all. Im trying to develop yet another email filter. Just for fun for >>now. Im having a little trouble parsing long 'To' and 'Cc' headers. >>Sometimes p.e. the 'To' header comes like >> >>'[EMAIL PROTECTED], [EMAIL PROTECTED]' >>others comes like >>'"My self" <[EMAIL PROTECTED]>, "My brother" <[EMAIL PROTECTED]>', >>other times a \r\t comes inside the `To' header. And any combination of >>the above mentioned (and shurely more) can ocur. >> >>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? >> >> >> >Have you tried using email.utils.getaddresses()? > >regards > Steve > > No, i was not. And it works just perfect! One day i will make a hard question!! I wonder why this getaddresess() function is not a method into the HeaderParser class. Ok, so my content-filter can continue now. Thanks Steve! Gerardo -- http://mail.python.org/mailman/listinfo/python-list
Re: parsing long `To' and 'Cc' from email
On Sep 6, 1:25 pm, Gerardo Herzig <[EMAIL PROTECTED]> 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. -- http://mail.python.org/mailman/listinfo/python-list
Re: parsing long `To' and 'Cc' from email
Gerardo Herzig wrote: > Hi all. Im trying to develop yet another email filter. Just for fun for > now. Im having a little trouble parsing long 'To' and 'Cc' headers. > Sometimes p.e. the 'To' header comes like > > '[EMAIL PROTECTED], [EMAIL PROTECTED]' > others comes like > '"My self" <[EMAIL PROTECTED]>, "My brother" <[EMAIL PROTECTED]>', > other times a \r\t comes inside the `To' header. And any combination of > the above mentioned (and shurely more) can ocur. > > 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? > Have you tried using email.utils.getaddresses()? regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - -- http://mail.python.org/mailman/listinfo/python-list
parsing long `To' and 'Cc' from email
Hi all. Im trying to develop yet another email filter. Just for fun for now. Im having a little trouble parsing long 'To' and 'Cc' headers. Sometimes p.e. the 'To' header comes like '[EMAIL PROTECTED], [EMAIL PROTECTED]' others comes like '"My self" <[EMAIL PROTECTED]>, "My brother" <[EMAIL PROTECTED]>', other times a \r\t comes inside the `To' header. And any combination of the above mentioned (and shurely more) can ocur. 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? Thanks! Gerardo -- http://mail.python.org/mailman/listinfo/python-list