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

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

问题描述

我遇到过这个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 user

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

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

    MAIL FROM:<>
    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.

    还有一种称为灰名单的反垃圾邮件技术,它会导致服务器最初拒绝该地址,期望真正的 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天全站免登陆