Search code examples
javaemailemail-verification

Is there any way to detect whether an email address belongs to an existing account?


There is way to detect whether an email id is well-formed or not. Example [email protected] is a well-formed email address, but this may or may not be valid email account.

  • Case 1 May be the domain doesnot exist (e.g. def.com here).
  • Case 2 If the domain is valid then may be the id doesnot exist for the domain (eg abcqs username doesnot exist for def domain).

If it is not valid then if we sent mail, we will get some delivery failure mail, maybe in some hours after sending the email.

I want to implement a similar concept. I want to verify if an email id belongs to a valid account, which will find out whether the account exists or not.

How to achieve it?


Solution

  • I think a better approach is to send an email and verify it the user activates the account.

    1. The user fills in his email
    2. You create a link to be acessed by the user, passing some parameter to him. Example: http://your.domain.com/activate?account=984239048302948203482390
    3. You save the email and all info in your database, with a flag (a field) indicating that it hasn't being activated yet, and the code you sent him
    4. When he clicks the link, you'll receive that parameter in your site, in some program you have wrote. So you'll know that the parameter 984239048302948203482390 has been used
    5. You verify if that code exists in your database and activate the account.

    And them he's verified.

    You can check your database, every x days, and remove all the old entries, like one that weren't validated more than one week ago.