473,382 Members | 1,791 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,382 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 3354
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.