Created
July 6, 2015 17:59
-
-
Save nawawi/2a8be1187150d7d5a3d4 to your computer and use it in GitHub Desktop.
check email
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
<?php | |
function _check_email($email, $strict = false) { | |
if ( filter_var($email, FILTER_VALIDATE_EMAIL) ) { | |
if ( $strict && function_exists("getmxrr") ) { | |
list($prefix, $domain) = split("@",$email); | |
return @getmxrr($domain, $maxhost); | |
} | |
return true; | |
} | |
return false; | |
} | |
// test | |
echo ( _check_email('mohd.nawawi@gmail.com', false) ? "OK" : "KO" ); | |
echo ( _check_email('mohd.nawawi@gmailaaa.com', true) ? "OK" : "KO" ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment