Check if an email exists or your email domain

Asked

Viewed 3,151 times

1

I need to check in Java if an email or your domain exists. I do not mean to treat the validity of the email, using for example regular expression, but rather actually check if there is an associated account. I saw some forums on the web but many outdated 2014 back, as I can do it today.

Example: [email protected]

I want to be able to check by full e-mail [email protected], and/or by domain @gmail.com, what is most feasible and possible to implement.

It would be something like what this site ago.

  • The google api-client-library, has an HTTP Request watch, POST https://www.googleapis.com/gmail/v1/users/userId/watch. where the userid is the email. If this email is invalid, return an error message. See link: https://developers.google.com/gmail/api/v1/reference/users/watch?hl=pt-BR

  • 2

    The only way to verify if an email exists (or if there is at least one alias) is to send the email and check if it was successful (preferably with a confirmation link). The rest is kick.

  • 2

    Unless you went to Google, for example, which has other ways of knowing this (probably the address of almost every person has passed through their servers countless times). Anyway, between knowing and releasing an API for this has an ethical chasm.

2 answers

7

Since not every email API supports checking the existence of a given email, there is probably no way to programmatically verify this. Some blogs suggest using telnet with the supposed email and check if you receive a 550 reply. This does not guarantee that the user has access to the email, besides being quite complex to do programmatically. As said in another answer to this question in the OS, you can send VRFY requests, which is not implemented on every server, or a RCPT request, which can be silently dropped and does not guarantee validity every time.

The most common implementation is two-step email verification, that is, you send an email with a confirmation link (which is accompanied by some verification token), and the user clicks on the link to confirm that the email is both valid and valid from it.

  • The problem I’m finding is this, that not all methods are guaranteed. The problem is that the two-step email validation does not fit my scenario, because the validation is not performed when the user registers. I wanted something like this site here: https://tools.verifyemailaddress.io/

  • 1

    This is the only valid response today. Without two-step verification, there is no guarantee that an email exists. In fact, I tested the tool indicated in the link, and the most that it informs of my domains is that it is not possible to check.

  • I understand the complexity. What about the second check I reported? Check if the domain is valid? " gmail.com", "yahoo.com", "Hotmail.com". That would have a way for me to check?

  • @Pedro there is a question of making a DNS request, in principle, and testing if there is any MX or if A or AAAA have SMTP.

  • @Bacco that’s what I did here, I used the Inetadress class of "java.net". I managed to solve my problem here.

5

For me, checking if an email exists only serves to send spam. So I don’t care how to solve this issue. I don’t even want to know if you have the mailbox address or the domain name.

Check if someone who is registering somewhere and has a valid email (in every sense), including if it is his, only has two solutions.

The first has already been cited the other reply, so I already voted on it, have to send a message to the user where he confirms that he received. It’s flawed, but it doesn’t have much to do. It actually works in almost every case if the UX is good.

The other is to do it right, that is, don’t ask the person to register, ask them to authenticate. Use his data requiring less effort than registering and know that not only does the email exist, but it belongs to those who are registering, with no other interaction besides immediate access to the authorization page of the authenticator chosen.

Could be the Google, Facebook, Microsoft, and many others, even some niche, as this site.

Look for Oauth (list of international providers), Single Sign On, User-Managed Access, Openid, OATH, just to stay on some.

None is a panacea. Use a fallback if the user cannot use such a provider, then confirm by sending a token for him to authenticate, the first solution.

If none of that settles, sit down and cry :)

  • 3

    If I could take a second vote, I’d only take the last paragraph

  • I understand this question, I solved the case in another way, requesting the DNS informed after the "@", so I can solve my problem. I understand that the best step would be to check from the user’s email confirmation, but in my case this does not apply, because I do not do this validation in the user registration process.

Browser other questions tagged

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