Last active
September 28, 2020 06:35
-
-
Save anxp/c096cf51a24c2e224741218056a09817 to your computer and use it in GitHub Desktop.
Simple email address validation - check syntax and MX record existing.
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 _nxte_redeem_is_email_valid($email) { | |
if (empty ($email)) {return false;} | |
list($user_name, $mail_domain) = explode('@', $email); | |
if (empty($user_name) || empty($mail_domain)) {return false;} | |
$is_syntax_ok = (bool) filter_var($email, FILTER_VALIDATE_EMAIL); | |
$is_MX_exists = checkdnsrr($mail_domain, 'MX'); | |
return ($is_syntax_ok && $is_MX_exists); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment