Last active
March 12, 2023 18:27
-
-
Save samin/f89c0f9b67ae82200e22 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function get_mx($email) | |
{ | |
// Get domain name from email | |
$domain = substr(strrchr($email, "@"), 1); | |
// get MX records for domain | |
getmxrr($domain, $mxhosts); | |
// Match records with three options | |
preg_match('/google|hotmail|yahoo/i', implode(' ', $mxhosts), $matches); | |
// return option | |
return strtolower($matches[0]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello samin, awesome script. Just a thing: in this case it should be
get_mx($email)
instead ofget_mx($domain)