Last active
December 17, 2015 17:59
-
-
Save mihai-vlc/5650198 to your computer and use it in GitHub Desktop.
PHP: isValidMail
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 isValidMail($mail) { | |
if(!filter_var($mail, FILTER_VALIDATE_EMAIL)) | |
return FALSE; | |
if(!checkdnsrr("gmail.com", "MX")) // if we have no internet access on the server | |
return TRUE; | |
list($username, $maildomain) = explode("@", $mail); | |
if(checkdnsrr($maildomain, "MX")) | |
return TRUE; | |
return FALSE; | |
} | |
var_dump(isValidMail("[email protected]")); | |
var_dump(isValidMail("[email protected]")); | |
var_dump(isValidMail("dfdsfs@")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment