简体   繁体   English

如何检查电子邮件地址的存在

[英]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 :您可以使用npm email-validator检查电子邮件地址的格式是否符合RFC5322

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.但是您要问的是,是否有一种通用且可靠的方法可以向 intertoobz 询问任何给定的电子邮件地址后面是否有真实的邮箱。

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.商业邮件服务(Constant Contact、MailChimp、SendGrid)提供将消息发送到邮箱请求许可以订阅电子邮件服务的功能。 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.只有在URL点击后才能确定地址存在。 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.他们为了避免发送垃圾邮件会遇到很多麻烦,因为大型电子邮件提供商(gmail、outlook.com、comcast、charter 等)经常将发送电子邮件的服务器列入黑名单,以降低垃圾邮件负载。 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.您可以在自己的应用程序中实现类似的“订阅权限”服务,但解释如何做到这一点超出了 StackOverflow 答案的范围。 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? 我可以使用 .net 检查电子邮件地址是否存在吗?

I've used SendGrid.com 's free service tier, and it works well.我使用了 SendGrid.com 的免费服务层,它运行良好。 I've also used MailChimp successfully.我也成功地使用了 MailChimp。

You can use a service like EmailChecker (I just did a quick google search) to check if the email really exists.您可以使用EmailChecker 之类的服务(我只是在谷歌上进行了快速搜索)来检查电子邮件是否真的存在。

To use the API you need to pay for premium but you can see how it works here: https://email-checker.net要使用 API,您需要支付高级费用,但您可以在此处查看它的工作原理: 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.否则,您所知道的就是某人的 SMTP 服务器接受了该消息。

See https://haacked.com/archive/2007/08/21/i-knew-how-to-validate-an-email-address-until-i.aspx/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? 如何在不发送电子邮件的情况下检查电子邮件地址是否存在?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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