473,231 Members | 1,826 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

test if email

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

Thanks,

florian
Oct 12 '07 #1
15 3351
On Oct 12, 2:55 pm, Florian Lindner <Florian.Lind...@xgm.dewrote:
Hello,
is there a function in the Python stdlib to test if a string is a valid
email address?

Thanks,

florian
What do you mean? If you're just testing the construction of the email
address string, then it's pretty easy. If you want to know if the
email address is live and works, the only way to reliably find that
out is to send a test email there to see if it goes through or
bounces.

Here's an interesting article on the topic, which is completely non-
Python related:

http://www.oreillynet.com/onlamp/blo...ail_addre.html

Mike

Oct 12 '07 #2
Florian Lindner wrote:
Hello,
is there a function in the Python stdlib to test if a string is a valid
email address?
Nope, most any string with an @ in it could be a valid email addy. Send
a message to the addy, if it doesn't bounce, then it's valid.
Oct 12 '07 #3
On 12/10/2007, Florian Lindner <Fl*************@xgm.dewrote:
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 :)
Oct 12 '07 #4
On 2007-10-12, brad <by*******@gmail.comwrote:
Florian Lindner wrote:
>Hello,
is there a function in the Python stdlib to test if a string is a valid
email address?

Nope, most any string with an @ in it could be a valid email addy. Send
a message to the addy, if it doesn't bounce, then it's valid.
Just because it doesn't bounce, that doesn't mean it's "valid".
Some servers don't bounce e-mail to invalid addresses, they
just drop them into the bit bucket in an effort to prevent
spammers from harvesting valid e-mail addresses using
dictionary attacks.

If you send an e-mail to an address and you get a response,
then it's valid.

--
Grant Edwards grante Yow! BARRY ... That was
at the most HEART-WARMING
visi.com rendition of "I DID IT MY
WAY" I've ever heard!!
Oct 12 '07 #5
On 12/10/2007, brad <by*******@gmail.comwrote:
Florian Lindner wrote:
Hello,
is there a function in the Python stdlib to test if a string is a valid
email address?

Nope, most any string with an @ in it could be a valid email addy. Send
a message to the addy, if it doesn't bounce, then it's valid.
Invalid email doesn't always bounce, ( or the bounces may not always reach you )

:)

--

Tim Williams
Oct 12 '07 #6
Grant Edwards wrote:
If you send an e-mail to an address and you get a response,
then it's valid.
No response could be valid too. The user may not respond. For automated
tasks, I go with the no bounce method. When things start bouncing, do
domething, but so long as they don't bounce do something else.
Oct 12 '07 #7
ky******@gmail.com wrote:
On Oct 12, 2:55 pm, Florian Lindner <Florian.Lind...@xgm.dewrote:
>Hello,
is there a function in the Python stdlib to test if a string is a valid
email address?
here's a Perl re example... I don't know whether to laugh or cry...
don't try to replicate this in Python or you'll hurt yourself. :)

"... the only sure way to see if a supplied email address is genuine is
to send an email to it and see if the user recieves it."

http://ex-parrot.com/~pdw/Mail-RFC822-Address.html
Oct 12 '07 #8
ky******@gmail.com wrote:
On Oct 12, 2:55 pm, Florian Lindner <Florian.Lind...@xgm.dewrote:
>Hello,
is there a function in the Python stdlib to test if a string is a valid
email address?

Thanks,

florian

What do you mean? If you're just testing the construction of the email
address string, then it's pretty easy. If you want to know if the
email address is live and works, the only way to reliably find that
out is to send a test email there to see if it goes through or
bounces.

Here's an interesting article on the topic, which is completely non-
Python related:

http://www.oreillynet.com/onlamp/blo...ail_addre.html

Answer to everybody:

I was just asking for the correct syntax of the mail address. I know about
the various problems actually impossibility to test for a live and valid
address.

Regards,

Florian
Oct 12 '07 #9
On 2007-10-12, brad <by*******@gmail.comwrote:
Grant Edwards wrote:
>If you send an e-mail to an address and you get a response,
then it's valid.

No response could be valid too.
Right. A->B doesn't mean that !A -!B

--
Grant Edwards grante Yow! Did I do an INCORRECT
at THING??
visi.com
Oct 12 '07 #10
On 2007-10-12, Florian Lindner <Fl*************@xgm.dewrote:
I was just asking for the correct syntax of the mail address. I know about
the various problems actually impossibility to test for a live and valid
address.
Don't forget to allow uucp style "bang" addresses. :)

--
Grant Edwards grante Yow! I had a lease on an
at OEDIPUS COMPLEX back in
visi.com '81 ...
Oct 12 '07 #11
On Oct 12, 4:59 pm, brad <byte8b...@gmail.comwrote:
kyoso...@gmail.com wrote:
On Oct 12, 2:55 pm, Florian Lindner <Florian.Lind...@xgm.dewrote:
Hello,
is there a function in the Python stdlib to test if a string is a valid
email address?

here's a Perl re example... I don't know whether to laugh or cry...
don't try to replicate this in Python or you'll hurt yourself. :)

"... the only sure way to see if a supplied email address is genuine is
to send an email to it and see if the user recieves it."

http://ex-parrot.com/~pdw/Mail-RFC822-Address.html
Gotta love the comment: "somewhat pushes the limits of what it is
sensible to do with regular expressions".

Now if this is not an understatement I don't know what is!

Oct 12 '07 #12
2007/10/12, Grant Edwards <gr****@visi.com>:
On 2007-10-12, Florian Lindner <Fl*************@xgm.dewrote:
I was just asking for the correct syntax of the mail address. I know about
the various problems actually impossibility to test for a live and valid
address.

Don't forget to allow uucp style "bang" addresses. :)
no need to get there most forms won't accept the new top level domains (.name).

No need to speek of plus addressing or older messaging systems.

Heck just check for an "@" and try to deliver it. (if there's no @ you
should know wether it's a local user or not....)

hth
martin

--
http://noneisyours.marcher.name
http://feeds.feedburner.com/NoneIsYours
Oct 12 '07 #13
On 2007-10-12, George Sakkis <ge***********@gmail.comwrote:
On Oct 12, 4:59 pm, brad <byte8b...@gmail.comwrote:
>kyoso...@gmail.com wrote:
On Oct 12, 2:55 pm, Florian Lindner <Florian.Lind...@xgm.dewrote:
Hello,
is there a function in the Python stdlib to test if a string is a valid
email address?

here's a Perl re example... I don't know whether to laugh or cry...
don't try to replicate this in Python or you'll hurt yourself. :)

"... the only sure way to see if a supplied email address is genuine is
to send an email to it and see if the user recieves it."

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

Gotta love the comment: "somewhat pushes the limits of what it is
sensible to do with regular expressions".
OK, I want to know if a human generate that RE, or if it was
generated mechanically from the grammar specification. It's
hard to imagine the former, but you never know when it comes to
Perl programmers.

--
Grant Edwards grante Yow! Hmmm ... an arrogant
at bouquet with a subtle
visi.com suggestion of POLYVINYL
CHLORIDE ...
Oct 12 '07 #14
Florian Lindner <Fl*************@xgm.dewrites:
is there a function in the Python stdlib to test if a string is a
valid email address?
Not to my knowledge.

Florian Lindner <Fl*************@xgm.dewrites:
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
Oct 13 '07 #15
Martin Marcher wrote:
No need to speek of plus addressing or older messaging systems.
But don't disallow a plus in the localpart. Many do.

Regards,
Björn

--
BOFH excuse #180:

ether leak

Oct 13 '07 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Berthold Hoellmann | last post by:
Hello, When I use ./configure --with-thread --with-fpectl --with-signal-module \ --with-pymalloc --enable-shared --with-cxx=g++ make test on 2.3.3 I get
9
by: Berthold Höllmann | last post by:
Hello, The error desribed in SF error report No. 870120 (segmentation fault in test_re) still persists for me in 2.3.4c1. Regards Berthold -- bhoel@web.de /...
9
by: Hudson Reis | last post by:
Hi all, Test, please ignore. Hudson
176
by: nw | last post by:
Hi, I previously asked for suggestions on teaching testing in C++. Based on some of the replies I received I decided that best way to proceed would be to teach the students how they might write...
0
by: Prometric Test center | last post by:
Bangalore's Best Prometric Test center (like Microsoft, Sun Microsystems, Dell, HP) Hi, Greetings from Everonn!!!! Are you looking for the good Prometric (like Microsoft, Sun Microsystems,...
0
by: Prometric Test center | last post by:
Bangalore's Best Prometric Test center (like Microsoft, Sun Microsystems, Exin - ITIL, Dell, HP) Hi, Greetings from Everonn!!!! Are you looking for the good Prometric (like Microsoft, Sun...
0
by: Prometric Test center | last post by:
Best Prometric Test center in Bangalore (like Microsoft, Sun Microsystems, Exin - ITIL, Dell, HP) Hi, Greetings from Everonn!!!! Are you looking for the good Prometric (like Microsoft, Sun...
4
by: istillshine | last post by:
I have a function foo, shown below. Is it a good idea to test each argument against my assumption? I think it is safer. However, I notice that people usually don't test the validity of...
0
by: Prometric Test center | last post by:
Best Prometric Test center in Bangalore (like Microsoft, Sun Microsystems, CISCO, Exin - ITIL, Dell, HP) Hi, Greetings from Everonn!!!! Are you looking for the good Prometric (like...
2
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
I was wonder if there is any protocol or suggestions on how to setup unit testing projects in large solution??? If you have a large solution of say 50 projects and add a project for every unit...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.