dns检测工具 php,PHP: checkdnsrr - Manual

Important Warning:

You need to add a dot to the end of the host name to make a fully qualified domain name.

To see why, try executing the following pieces of code:

$d1="gmail.con";

$d2="gmail.con.";

$r1=checkdnsrr($d1, "MX");

$r2=checkdnsrr($d2, "MX");

var_dump($r1);

var_dump($r2);

You will see that without the dot it claims that the domain "gmail.con" is valid.

Note that if you time the "checkdnsrr()" calls you will also see it takes longer without the dot because it treats it as a relative domain and does several tries based on the host name it is running on.

NB: in case you're interested, being treated as a relative domain explains what is happening. If your host is "example.com" the relative domain will eventually resolve to "gmail.con.com." which can be looked up, hence it wrongly claims "gmail.con" exists

您好,您的问题是关于邮箱批量验证系统PHP的。为了开发一个邮箱批量验证系统,您需要了解以下几个步骤: 1. 从一个文本文件中读取所有需要验证的邮箱地址。 2. 使用PHP的SMTP库来连接到每个邮箱服务器,以验证邮箱地址的有效性。 3. 在验证过程中,需要检查MX记录以确保邮件服务器存在,以及检查SMTP服务器以确保邮箱地址是可用的。 4. 将验证结果保存到一个新的文件中,以备将来使用。 下面是一个简单的PHP代码示例,用于验证单个邮箱地址的有效性: ``` function verifyEmail($email) { $isValid = true; // Validate email address syntax if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $isValid = false; } // Get domain name from email address $domain = substr(strrchr($email, "@"), 1); // Verify MX record exists if ($isValid && !checkdnsrr($domain, "MX")) { $isValid = false; } // Verify SMTP server can accept mail if ($isValid) { $mxhosts = array(); getmxrr($domain, $mxhosts); foreach ($mxhosts as $mx) { $socket = fsockopen($mx, 25, $errno, $errstr, 10); if ($socket) { stream_set_timeout($socket, 10); $reply = fgets($socket, 4096); fclose($socket); if (preg_match("/^220/", $reply)) { break; } } } if (!$socket) { $isValid = false; } } return $isValid; } ``` 您可以使用此函数来验证单个邮箱地址的有效性。要批量验证多个邮箱地址,您可以编写一个循环来遍历输入文件中的所有邮箱地址,并为每个地址调用此函数。然后将验证结果保存到输出文件中。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值