test if email

Ben Finney bignose+hates-spam at benfinney.id.au
Fri Oct 12 21:01:53 EDT 2007


Florian Lindner <Florian.Lindner at xgm.de> writes:

> is there a function in the Python stdlib to test if a string is a
> valid email address?

Not to my knowledge.

Florian Lindner <Florian.Lindner at xgm.de> writes:

> I was just asking for the correct syntax of the mail address.

Well, you weren't actually (I can't interpret your question above in
this way), but to answer this new question, read RFC 3696 §3:

    RFC 3696: Application Techniques for Checking and Transformation of Names
    <URL:http://www.ietf.org/rfc/rfc3696.txt>

> I know about the various problems actually impossibility to test for
> a live and valid address.

As you'll see from the above, the only thing you can check for
"validity" is the domain. The local-part can consist of *any*
printable ASCII characters, including "@" and any other punctuation.
Only the final delivery host gets to say whether it's valid or not.

-- 
 \      "Saying that Java is nice because it works on all OSes is like |
  `\    saying that anal sex is nice because it works on all genders"  |
_o__)                                              -- http://bash.org/ |
Ben Finney



More information about the Python-list mailing list