i have my own website and i want to put a login function in it.now whenever any user registers himself on the website he would write his email address, but how would my login function check whether that email address really exists or not.i mean suppose any body enters the email address of yahoo or maybe gmail .how would i check whether that email address really exist in yahoo or gmails database.? how can i validate that email address. ? can anybody help me in this problem? thanks in advance.
-
Check where? JavaScript, PHP, Python, Ruby, Java ... – Tomasz Karbownicki Jun 03 '11 at 12:44
2 Answers
You can't check an email address account actually exists without actually sending it a message, as far as I know.
The standard way of verifying email accounts for web systems is to send a validation email to the account the user specifies, containing either a link they have to click that redirects back to your site with a verification key in the URL, or containing a validation code the user has to enter on the website. Either way, it will allow you to (a) verify they own the mailbox, and (b) confirm its existence (a send failure or a bounce-back from the mail server should indicate the account is invalid).
You could set the user account in an 'unverified state' until the user validates the mailbox, and only let them access the full login-restricted parts of the site once this validation has occurred.
EDIT: As Pascal Wittmann points out, there ARE ways of verifying an account, but whether the methods work depend on whether the mail server being used allows such queries. I would say best practice is to validate the email by the above method, to make sure the user has entered an email address they own - otherwise you may end up sending emails to a user who doesn't want them!

- 2,083
- 19
- 27
What you can do is ensure that the user registering on your website is using a valid email address by sending him a verification mail.
In that mail you add a link with a token that goes to your website. I.e. Like this http://www.mysite.com/user/verify/123123.
Then you just need to verify that 123123 is a valid token. (The token should be a randomized string, that is unique for every user)
And if the user clicks that link, you know for sure that he got a valid email address. Simple as that.

- 2,016
- 3
- 15
- 26