Created
December 1, 2008 18:31
-
-
Save kgaughan/30797 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function is_valid_local_part($local) { | |
// I'm not entirely sure about this regex, but it seems to fit was RFC2822 specifies. | |
return preg_match("@^[-a-z0-9!#\$%&'*+/=?^_`{|}~]+(\.[-a-z0-9!#\$%&'*+/=?^_`{|}~]+)*\$@", $local); | |
} | |
function is_well_formed_email_address($email) { | |
// We ignore legacy addresses and local addresses. | |
$parts = explode('@', $email, 2); | |
if (count($parts) != 2) { | |
return false; | |
} | |
list($local, $host) = $parts; | |
return is_valid_local_part($local) && is_well_formed_hostname($host); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment