Advertisement
Guest User

Openerp 6.1 mail_message.py to_email

a guest
Mar 31st, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. def to_email(text):
  2.     """Returns a list of the email addresses found in ``text``
  3.    
  4.     According to rfc2822 the allowed characters are letter and digits and  
  5.            "!" / "#" /     ;  SP, and specials.
  6.                        "$" / "%" /     ;  Used for atoms
  7.                        "&" / "'" /
  8.                        "*" / "+" /
  9.                        "-" / "/" /
  10.                        "=" / "?" /
  11.                        "^" / "_" /
  12.                        "`" / "{" /
  13.                        "|" / "}" /
  14.                        "~"
  15.    Therefore remove also " and () around the addresses
  16.    and additionally ' because it is sometimes added to names that are taken from email address
  17.    and doubt that other clients can handle it.
  18.    
  19.    Warning: can create double entries                    
  20.                      
  21.    """
  22.     if not text: return []
  23.     return re.findall(r'([^ ,(\'"<@]+@[^> ,)\'"]+)',text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement