How do I check if an email actually exists?

Asked

Viewed 21,909 times

30

I made an email field for the user to register, and now I need a system to check if this email exists.

I need that when the user type his email a system check if it exists, if it even has this email. For example the user type: usuá[email protected], then it will appear on the side: "valid email" or "invalid email".

I’ve researched email validation system but no concrete results appear. Can anyone help me?

  • Although it is not clear it seems very broad: there are several e-mail systems, each one with its particularities. If the author made himself he should know how to solve it.

  • If you are using a third party system such as Gmail, you can only know if the email is valid or not. If you are using a system of your own lost said. Also, if it’s a login page just say something is wrong, for security.

  • There are still other implications, such as: if the case is a registration form, say that the email is already being used; if you are using Google Apps, or similar, use the Apis. This still varies from the language used, commonly we work with PHP but you can use another: I find it a little broad.

  • As far as I know, bfavaretto’s answer is the correct one. This post has some interesting things (How to check if an email address exists without sending an email?), but in the end it all seems quite experimental.

  • Impossible to validate is not, but it takes work and you need to open the door of Telnet! See explanation in the article: > How to test if an email account is valid/exists without sending an email,

5 answers

45


Without user interaction you will only be able to check whether the email is valid (well-formed) or not.

Although the SMTP protocol allows the verification of accounts, several email servers no longer offer this function due to the abuse of this function by spammers.

To check if the email really exists, it is necessary to create an extra step in your registration. When you register, register your status as "pending" or something like that, and send a confirmation email to the given address. The email must contain a unique link from that user, such as a hash of the informed email + some arbitrary value such as salt.

When the user accesses the link (which points to your system), you check the hash passed, and update the status to "registered".

13

It is impossible to perform a definitive validation of an email address because many target SMTP servers accept messages even for addresses that do not exist, and maybe only then return a message to a sender stating that the email is not valid.

However what you can do is simulate sending a message to the given email address and see if the target SMTP server would accept the recipient.

For this you need to consult the DNS to obtain the MX record of the domain informed and so know which server or servers would receive the message for that domain. You can give 1 server, several or even none. In the latter case the server to be used must be the one of the record A of the domain.

Then connect to port 25 of each server. If one of them already refuses the recipient, you already know that it is invalid. If one of them says yes, you’ll know it’s valid. If no server accepts the connection or gives an error with 4XX code, it is not possible to know if it is valid, because it is a situation that can be temporary.

Implementing this algorithm properly is a bit of a hassle. However, I developed one myself PHP class for email validation that already implements all these steps and has been improved since 1999.

In addition the class even allows you to define a list of domains that you will never want to accept emails, such as those from temporary disposable emails.

9

It is quite complex because it involves various techniques. The most common technique is email with account validation link. It helps a lot but is insufficient because often email falls into the spam box or sometimes it is not sent or even when it is valid, the user does not bother to click on the validation link.

Another technique is to create a bug on the response email server. For example, send a confirmation email whose reply email will be to a special email where the pop server will be waiting for a reply. It usually returns "mail undeliverable" message when the target server refuses an account even if it has settings to receive "Trash emails". The most popular and easy to implement filter is with the procmail, under Linux systems.

But be careful when marking an email as invalid because it may occur that a non-existent email will exist later. Example:

The [email protected] probably doesn’t exist. Assuming validation is made today, it will return as invalid. But if tomorrow someone creates exactly the same account? So never mark an email as invalid permanently.

7

I think you could do the following: When anyone includes the email and clicks send, your system sends them a message that they enter in the email and make the confirmation. Hence your system receives confirmation and registration. If it does not confirm, your system does not register.

1

You can send a message with email validation link to the email address you entered, as soon as clicked the user is redirected to your system and the email is given as valid.

There are other services that do email checking, follow link from one of these most famous services.

https://www.emailhippo.com/en-US/solutions

Browser other questions tagged

You are not signed in. Login or sign up in order to post.