简体   繁体   中英

How to check the existence of an email address

I am in charge of developing an application that needs to upload a lot of user data in a batch way. One of the users' data is an email address and we need to make sure that this email address really exists so that we can send a welcome message.

So, how could I check if an email address really exists?

You can check the format of an email address for RFC5322 compliance using npm email-validator :

const validator = require('email-validator')
...
if (validator.validate('test@email.com')) {
   /* email format is correct */
}

But you're asking if there's a general and reliable way to ask the intertoobz if there's a real mailbox behind any given email address.

The answer is no , except by sending a message to the mailbox and asking the recipient to respond. There are unreliable ways to check for a mailbox's existence, but many mail transfer agents do not implement them. Why not? Spam.

Commercial mail services (Constant Contact, MailChimp, SendGrid) offer features to send a message to a mailbox requesting permission to give it a subscription to an email service. The person behind the mailbox usually responds by clicking a hyperlink. The hyperlink contains a nonce -- a hard-to-guess random value -- that identifies the mailbox. Only after the URL click can you be sure the address exists. Sometimes end-users are asked to "confirm your email address" using this technique.

Those same services are good about tracking email bounces and failures, so they can have a temporary idea about what mailboxes don't exist. They go to a lot of trouble to avoid sending junk, because the big email providers (gmail, outlook.com, comcast, charter, and the rest) routinely blacklist servers sending email, to lower their spam load. When you use a service, you're paying for a lot of network-engineering work to prevent blacklisting.

You can implement a similar "permission to subscribe" service in your own application, but explaining how to do that is beyond the scope of a StackOverflow answer. Keeping it from being blacklisted? Probably very difficult unless your volume is very low.

See this for more discussion.

Can I check if an email address exists using .net?

I've used SendGrid.com 's free service tier, and it works well. I've also used MailChimp successfully.

You can use a service like EmailChecker (I just did a quick google search) to check if the email really exists.

To use the API you need to pay for premium but you can see how it works here: https://email-checker.net

Validating that an email address is a legal (eg, mailable ) format is one thing, but it doesn't tell you that there's a mailbox at that address. The only way to know if an email address "exists" is to mail something to it. If it [eventually] bounces, you can be pretty sure that it doesn't exist. Otherwise, all you know is that somebody's SMTP server accepted the message.

See https://haacked.com/archive/2007/08/21/i-knew-how-to-validate-an-email-address-until-i.aspx/

and this:

How to check if an email address exists without sending an email?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM