如何验证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);
}