如何通过PHP知道一个电子邮件地址是否存在?

发布于 2024-10-03 06:37:01 字数 98 浏览 4 评论 0原文

有些人通过输入他们的电子邮件地址订阅了我的博客。

但有些电子邮件地址不存在。

当我向这些电子邮件地址发送电子邮件时,如何知道这些电子邮件地址是否有效?

Some people have subscribed to my blog by entering their email address.

But some of the email addresses don’t exist.

How can I know if these email addresses are valid when I send an email to these email addresses?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

晚雾 2024-10-10 06:37:01

向他们发送一封带有链接的确认邮件,仅当他们单击该链接时才激活订阅。

Send them a confirmation mail with a link, and activate the subscription only if they click that link.

放低过去 2024-10-10 06:37:01

据我所知,你不能。当您无法发送电子邮件时,您就会知道该电子邮件无效,无论是因为域不存在还是该域上不存在帐户。

如果您想确保仅使用真实帐户进行订阅,请发送一封确认电子邮件,用户在其中单击链接来验证其帐户(如 casablanca 所说 此处)。

As far as I know, you can't. You'll know that the email is not valid when you fail to deliver the email, whether it's because the domain doesn't exists or the account doesn't exists on that domain.

If you want to make sure only real accounts are used to subscribe, send a confirmation email where the user clicks a link to validate his account (like casablanca says here).

半窗疏影 2024-10-10 06:37:01

您永远无法 100% 确定所提供的电子邮件地址确实存在。

一种方法是使用 SMTP VRFY 命令指示目标邮件中继确认收件人。但很多服务器不提供此功能。它还需要直接 SMTP 通信来进行检查。

即使目标服务器不拒绝您的收件人,收件人也可能不存在,因为某些服务器会接受所有传入电子邮件并在稍后阶段将其退回。

您可以实现以下命令(或使用为您执行此操作的众多 PHP 脚本之一):

HELO <your server name>
MAIL FROM: <>
RCPT TO: <[email protected]>
QUIT

You'll never be 100% sure that a provided email address really exists.

One way would be to use the SMTP VRFY command to instruct the destination mail relay to confirm the recipient. But many servers don't provide this feature. It also requires direct SMTP communication to do the check.

Even when the destination server doesn't refuse your recipient, the recipient may not exist, as some servers accept all incoming emails and bounce them back at a later stage.

You may implement the following commands (or use one of the many PHP scriplets that do it for you):

HELO <your server name>
MAIL FROM: <>
RCPT TO: <[email protected]>
QUIT
疾风者 2024-10-10 06:37:01

您可以执行 MX 记录查找

$result = getmxrr($hostname, $mxHosts);
if(count($mxHosts) < 1){
   //no MX records found
}

: protected]'-输入类型。请参阅 php.net 上的手册页: http://www.php.net/手册/en/function.getmxrr.php

You can do an MX record lookup with:

$result = getmxrr($hostname, $mxHosts);
if(count($mxHosts) < 1){
   //no MX records found
}

This will prevent your users from using the '[email protected]'-type of input. See the manual page on php.net: http://www.php.net/manual/en/function.getmxrr.php

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文