test if email

Tim Williams tdwdotnet at gmail.com
Fri Oct 12 22:45:41 CEST 2007


On 12/10/2007, Florian Lindner <Florian.Lindner at xgm.de> wrote:
> Hello,
> is there a function in the Python stdlib to test if a string is a valid
> email address?
>

You mean a valid SMTP email address?

In reality, there isn't a way of doing this.  But a good rule of thumb
is if it hasn't got at least one '@' symbol with at least one '.' to
the right of the right-most '@' symbol then it isn't valid for
internet transmission.

If you meant "test if a string is an existing email address",  then
again there is no foolproof way of testing.   Valid email addresses
can bounce for a variety of reasons, and invalid email addresses don't
always bounce.  Using an SMTP dialogue with the server without sending
an email can have the same bounce/non-bounce (actually, accept/refuse)
results.

HTH :)



More information about the Python-list mailing list