Skip to content

Instantly share code, notes, and snippets.

@anxp
Last active September 28, 2020 06:35
Show Gist options
  • Save anxp/c096cf51a24c2e224741218056a09817 to your computer and use it in GitHub Desktop.
Save anxp/c096cf51a24c2e224741218056a09817 to your computer and use it in GitHub Desktop.
Simple email address validation - check syntax and MX record existing.
<?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