Skip to content

Instantly share code, notes, and snippets.

@mihai-vlc
Last active December 17, 2015 17:59
Show Gist options
  • Save mihai-vlc/5650198 to your computer and use it in GitHub Desktop.
Save mihai-vlc/5650198 to your computer and use it in GitHub Desktop.
PHP: isValidMail
<?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