Test for Existence of Email Server
Posted: Mon Jan 30, 2017 3:36 pm
The conditional test in the following function is derived from the first edition of "Web Database Applications with PHP and MySQL." This book was published by O'Reilly. Using the PHP function "getmxrr" makes prefect sense. However, I am unsure about the usefulness of the "checkdnsrr" test.
Code: Select all
<?php
function test_email_server($email)
{
if (!(getmxrr(substr(strstr($email, '@'), 1), $temp) ||
checkdnsrr(gethostbyname(substr(strstr($email, '@'), 1)), "ANY")))
{
return false;
}
else
{
return true;
}
}
?>