【发布时间】:2018-02-20 19:22:42
【问题描述】:
我通过我网站中的表格要求提供电子邮件地址。我想验证域,以便我可以防止我现在收到的虚假条目。我正在使用以下代码,但它似乎不起作用:
function myCheckDNSRR($hostName, $recType = '')
{
if(!empty($hostName)) {
if( $recType == '' ) $recType = "MX";
exec("nslookup -type=$recType $hostName", $result);
// check each line to find the one that starts with the host
// name. If it exists then the function succeeded.
foreach ($result as $line) {
if(eregi("^$hostName",$line)) {
echo "valid email";
}
}
// otherwise there was no mail handler for the domain
echo "invalid email";
}
echo "invalid EMAIL";
}
我是新手,使用了here的代码
请指导我。谢谢。
【问题讨论】:
-
它似乎不起作用你得到什么错误?
-
为什么不像世界其他地方一样发送一封带有确认链接的电子邮件?
-
没有具体的错误。但来自用户的电子邮件地址未经过验证。
-
ereg()?那是 PHP 4 代码!使用验证库! -
@AlexK。你能说得更具体些吗
标签: php validation email