1

Possible Duplicate:
Determining the health/validity of an email address

How do I check whether the email address actually exist using Java and PHP? when the user type in an email address in the email field, beside the email of the form it will display whether it is valid or exist email address. First it will check whether it is in the correct format 'name@domain.com', Secondly it will check whether the email address is real and existing.

Community
  • 1
  • 1
PSY
  • 43
  • 2
  • 7
  • You'd be interested in the answers to [this question](http://stackoverflow.com/questions/504631/determining-the-health-validity-of-an-email-address?rq=1). – Carsten Jun 29 '12 at 09:17

4 Answers4

1

You can't. You can only check your own database to see if a user already exists with that email address. But to check whether it's real you'll have to send a verification email and let the user click on a link in the email. This demonstrates that at least one person can receive emails on that email address.

Simeon Visser
  • 118,920
  • 18
  • 185
  • 180
1

Instantly? impossible. If time's not that important, you can always try to directly communicate with the SMTP server for that domain. (you know, how to find it via dns MX records, don't you? ) Some of them will give you a 'user-not-exists' error, some of them won't. Some of them will force you into greylisting, so the whole process can take anywhere from a few secs to 15 minutes or so...

The point is: if you have a good captcha solution, worrying about fake emails is not that much of an issue I guess.

Gergely Szilagyi
  • 3,813
  • 1
  • 14
  • 12
0

ditto the Simeon Visser and raina77ow comment

Also due to new regulations coming out soon that allow foreign characters in domain names, the only way to check if an email address is in the correct format is that it has a character followed by @ followed by a character (currently 3 or more characters) that is not a . or a space, followed by a . then some more characters that are not a space (that include a .)

so xxxx@xxx.xx is ok at present

but 新@書.中 WILL BE VALID SOON

Waygood
  • 2,657
  • 2
  • 15
  • 16
  • Apparently I'm a little behind the times http://en.wikipedia.org/wiki/Internationalized_domain_name – Waygood Jun 29 '12 at 09:31
0

There is no easy way to verify the address exists in one hit. You can verify that its of the correct form using a regex, even this is trickier than it first seems. If you make it too restrictive you'll find some users won't be able to register. I would say it's better to just have some simple validation to make sure it has an @ sign. In order to actually verify it most sites send a verification email with an activation code/link. It's simple and it works and most users will be familiar with the process now.

Ben Thurley
  • 6,943
  • 4
  • 31
  • 54