how to verify an email address in php?

Possible Duplicate:
Is there a php library for email address validation?

how to verify a email address in php?


If you want to check if an email address exists, check out checkdnsrr:

if (checkdnsrr('you@user.com', 'MX')) {
    echo ':)';
}
else {
   echo ':(';
}

If you want to check if a string is an email address, there are literally millions of regulars expressions out there. There's a native function in php, filter_input that does it, thought I've personally never used it.


filter_var($input, FILTER_VALIDATE_EMAIL)


function isemail($email) {
    return strlen($email) > 6 && preg_match("/^[w-.]+@[w-.]+(.w+)+$/", $email);
}
链接地址: http://www.djcxy.com/p/92716.html

上一篇: 正则表达式将电子邮件地址与地址标签进行匹配

下一篇: 如何验证在PHP中的电子邮件地址?