Validating an email address

Tom Anderson twic at urchin.earth.li
Fri Dec 9 06:10:04 EST 2005


Hi all,

A hoary old chestnut this - any advice on how to syntactically validate an 
email address? I'd like to support both the display-name-and-angle-bracket 
and bare-address forms, and to allow everything that RFC 2822 allows (and 
nothing more!).

Currently, i've got some regexps which recognise a common subset of 
possible addresses, but it would be nice to do this properly - i don't 
currently support quoted pairs, quoted strings, or whitespace in various 
places where it's allowed. Adding support for those things using regexps 
is really hard. See:

http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html

For a level to which i am not prepared to stoop.

I hear the email-sig are open to adding a validation function to the email 
package, if a satisfactory one can be written; i would definitely support 
their doing that.

tom

-- 
Women are monsters, men are clueless, everyone fights and no-one ever
wins. -- cleanskies



More information about the Python-list mailing list