tags:

views:

72

answers:

2

Possible Duplicate:
How far should one take e-mail address validation?

Hi all

How to check if a mail address is valid? Not the format, just the mail address. For example, I random type a address like [email protected], is there any way to check if this address is valid?

Best Regards,

+4  A: 

Other than sending an email, and maybe not getting an error sent back, no there's not.

If there was a way, trust me, you'd be way more overloaded with spam than you are now :)

Nick Craver
+5  A: 

There's no 100% foolproof method. Format is quite straightforward with regex. To check whether the email address is a 'real' one, there are a number of possible checks. I'll name a few, some of which can be daisy-chained.

  • checking the domain exists
  • checking domain mx record(s) exists
  • checking domain mail server(s) can be connected
  • send a smtp check on the user name at the domain mailserver
  • send an actual email to the address

Above is not a exhaustive list, bear in mind many other factors come into play e.g. spam filters, blacklisting etc etc

o.k.w
+1 for no 100% foolproof method and a pretty good list.
kenny
Actually, that last on the list _is_ 100% foolproof. Send an email to that address with a link to click indicating that it was received. When the link is clicked, activate the email address. If nothing within N days, throw away all records about it. That's really the only one you need. +1.
paxdiablo
@paxdiablo, well, if the email header/subject/body trigger and get caught by spam filters, there might not be any response even though the email is legitimate. Or the email is sent from a blacklisted IP, or.. well, the list goes on.
o.k.w
I was thinking more in terms of checking to see if the address was usable. If your source site is blacklisted or the email will be filtered, then probably neither the confirm email nor any others would get through so there'd be no point using that address. But your point is taken.
paxdiablo
@paxdiablo, your point is valid too. I was listing some of the less invasive method which might check that the email is not valid (e.g. non-existing domain) before trying to send an email out (which I consider invasive).
o.k.w
"Format is quite straightforward with regex" -> nope. See previous questions about this.
Mauricio Scheffer
@Mauricio, ermm ok, "Format is less tricky", yea?
o.k.w
@o.k.w I wouldn't call a 6700-char regex "simple": http://cpansearch.perl.org/src/RJBS/Email-Valid-0.181/lib/Email/Valid.pm
Mauricio Scheffer
ah, you got me there :)
o.k.w