如何让 checkdnsrr 使用 Spamhaus.org 而不是 MX?

发布于 2025-01-03 22:49:45 字数 592 浏览 0 评论 0原文

我已获得此代码用于测试并验证传入的电子邮件地址是否有效。我知道这行得通,但圣诞节期间所有礼物的价格标签都被取消了。

就我而言,说明已被删除。根据我在这个脚本中看到的内容,“MX”告诉脚本使用 MX 验证数据库...我是否只需替换或添加它旁边的“spamhaus.org”即可使其工作?或者还不止于此?

我的服务器不是在 Windows 机器上,所以我不需要担心 checkdnsrr 不起作用。

另外,这个脚本有更好的版本吗?我很好奇,因为不幸的是 PHP 编码的这一部分对我来说是新的。

提前致谢。

// take a given email address and split it into the username and domain.
list($userName, $mailDomain) = split("@", $email);
if (checkdnsrr($mailDomain, "MX")) {
  // this is a valid email domain!
}
else {
  // this email domain doesn't exist! bad dog! no biscuit!
} 

I've been given this code to utilize to test out, and verify if email addresses coming in are valid. I know this works, but again with all gifts during Christmas the price tag has been removed.

In my case, the instructions have been stripped. I am taking by what I see in this script that the "MX" is telling the script to use the MX Verify database... do I just replace or add next to it ,"spamhaus.org" to make it work? Or is it more than that?

I am not on a windows machine as my server so I don't need to worry checkdnsrr not working.

Also, is there a better version of this script out there? I'm curious because unthankfully this part of PHP coding is new to me.

Thanks in advance.

// take a given email address and split it into the username and domain.
list($userName, $mailDomain) = split("@", $email);
if (checkdnsrr($mailDomain, "MX")) {
  // this is a valid email domain!
}
else {
  // this email domain doesn't exist! bad dog! no biscuit!
} 

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

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

发布评论

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

评论(1

提赋 2025-01-10 22:49:45

来自 http://php.net/manual/en/function.checkdnsrr.php 唯一支持的方法checkdnsr 的值为 A、MX、NS、SOA、PTR、CNAME、AAAA、A6、SRV、NAPTR、TXT 或 ANY。您无法添加自定义 URL。

尝试:

$host = '64.53.200.156';

$rbl  = 'sbl-xbl.spamhaus.org';
// valid query format is: 156.200.53.64.sbl-xbl.spamhaus.org
$rev = array_reverse(explode('.', $host));

$lookup = implode('.', $rev) . '.' . $rbl;

if ($lookup != gethostbyname($lookup)) {
    echo "ip: $host is listed in $rbl\n";
} else {
    echo "ip: $host NOT listed in $rbl\n";
}

From http://php.net/manual/en/function.checkdnsrr.php the only supported methods for checkdnsr are A, MX, NS, SOA, PTR, CNAME, AAAA, A6, SRV, NAPTR, TXT or ANY. you can't add in a custom URL.

Try:

$host = '64.53.200.156';

$rbl  = 'sbl-xbl.spamhaus.org';
// valid query format is: 156.200.53.64.sbl-xbl.spamhaus.org
$rev = array_reverse(explode('.', $host));

$lookup = implode('.', $rev) . '.' . $rbl;

if ($lookup != gethostbyname($lookup)) {
    echo "ip: $host is listed in $rbl\n";
} else {
    echo "ip: $host NOT listed in $rbl\n";
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文