Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kroatoanweb/fad0acf1738f7fc3b7a8327bc5b8554e to your computer and use it in GitHub Desktop.
Save kroatoanweb/fad0acf1738f7fc3b7a8327bc5b8554e to your computer and use it in GitHub Desktop.
<?php
/**
*
* Valida un email usando filter_var y comprobar las DNS.
* Devuelve true si es correcto o false en caso contrario
*
* @param string $str la dirección a validar
* @return boolean
*
*/
function is_valid_email($str)
{
$result = (false !== filter_var($str, FILTER_VALIDATE_EMAIL));
if ($result)
{
list($user, $domain) = split('@', $str);
$result = checkdnsrr($domain, 'MX');
}
return $result;
}
@EOM
Copy link

EOM commented Feb 10, 2021

change old split( for preg_split( PHP 5.6 >=

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment