如何检查电子邮件地址是否存在,而不发送电子邮件? [英] How to check if an email address exists without sending an email?

查看:195
本文介绍了如何检查电子邮件地址是否存在,而不发送电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看过这个 PHP代码检查电子邮件地址使用SMTP,而不发送电子邮件

有没有人尝试任何类似的东西为你工作?你能告诉一个电子邮件客户/用户输入是否正确&存在?

Has anyone tried anything similar or does it work for you? Can you tell if an email customer / user enters is correct & exists?

推荐答案

有两种方法可以用来确定收件人是否真实存在:

There are two methods you can sometimes use to determine if a recipient actually exists:


  1. 您可以连接到服务器,并发出VRFY命令。很少的服务器支持这个命令,但是这是为了这个。如果服务器使用2.0.0 DSN进行响应,则该用户就会存在。

  1. You can connect to the server, and issue a VRFY command. Very few servers support this command, but it is intended for exactly this. If the server responds with a 2.0.0 DSN, the user exists.

VRFY用户

您可以发出RCPT,看看邮件是否被拒绝。

You can issue a RCPT, and see if the mail is rejected.

MAIL FROM:<>

MAIL FROM:<>

RCPT TO:< user @ domain>

RCPT TO:<user@domain>

如果用户不存在,您将获得5.1.1 DSN。但是,只是因为电子邮件不被拒绝,并不意味着用户存在。某些服务器会默认地丢弃这样的请求,以防止其用户的枚举。其他服务器无法验证用户,并且不得不接受该消息。

If the user doesn't exist, you'll get a 5.1.1 DSN. However, just because the email is not rejected, does not mean the user exists. Some server will silently discard requests like this to prevent enumeration of their users. Other servers cannot verify the user, and have to accept the message regardless.

还有一种称为greylisting的反垃圾邮件技术,这将导致服务器最初拒绝该地址,期望一个真正的SMTP服务器会在稍后一段时间尝试重新发送。这将会使尝试验证地址。

There is also an antispam technique called greylisting, which will cause the server to reject the address initially, expecting a real SMTP server would attempt a re-delivery some time later. This will mess up attempts to validate the address.

老实说,如果您尝试验证地址,最好的方法是使用一个简单的正则表达式来阻止明显的无效地址,然后将具有链接的实际电子邮件发送回您的系统,以验证收到的电子邮件。这也确保他们的用户输入他们的实际电子邮件,而不是轻易的错别字属于别人。

Honestly, if you're attempting to validate an address the best approach is to use a simple regex to block obviously invalid addresses, and then send an actual email with a link back to your system that will validate the email was received. This also ensures that they user entered their actual email, not a slight typo that happens to belong to somebody else.

这篇关于如何检查电子邮件地址是否存在,而不发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆