Skip to content

Instantly share code, notes, and snippets.

@gelinger777
Created September 4, 2018 10:17
Show Gist options
  • Save gelinger777/1a3a3931c5b199978478d0cdfd184f4b to your computer and use it in GitHub Desktop.
Save gelinger777/1a3a3931c5b199978478d0cdfd184f4b to your computer and use it in GitHub Desktop.
public static function isEmail($email)
{
$parsed=explode("@",$email);
if(count($parsed)<2){
return false;
}
else{
$domain=$parsed[1];
if(checkdnsrr($domain)) {
// Domain at least has an MX record, necessary to receive email
}
else{
return false;
}
}
return !empty($email) && preg_match(Tools::cleanNonUnicodeSupport('/^[a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]+[.a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]*@[a-z\p{L}0-9]+(?:[.]?[_a-z\p{L}0-9-])*\.[a-z\p{L}0-9]+$/ui'), $email);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment