作者在 2021-05-13 08:17:26 发布以下内容
<?php
$email = 'test@126.c.om';
function testEmail($email)
{
//格式验证
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
return '邮箱格式有误!';
}
//dns验证
$mail = explode('@', $email);
$email = $mail[1];
if (!checkdnsrr($email,'ANY')) {
return '无效邮箱!请核对邮箱地址';
}
return 'success!';
}
$res = testEmail($email);