Kilian CAVALOTTI wrote:
>          from_str = self.to_unicode(msg['from'])
> +        # if space in from_str, extract real mail address
> +        if ' ' in from_str:
> +            import re
> + email_re = re.compile(r"([\w\d_\.\-])+\@(([\w\d\-])+\.)+([\w\d]{2,4})+")
> +            mo = email_re.search(from_str)
> +            if mo:
> +              from_str = mo.group(0)
> +

What about something like this (warning, untested):

from email.Utils import parseaddr
from_str = self.to_unicode(parseaddr(msg['from'])[1])

Don't want to knock regex or anything, but seems like it's a little bit more straightforward.

Btw, I like what you've done.

-John
_______________________________________________
Trac mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac

Reply via email to