Check DNS record from email address in PHP

Description

The following code shows how to check DNS record from email address.

Example


<?php//from   www  .  ja v  a  2s .com
    $email = "ceo@example.com";
    $domain = explode("@",$email);
  
    $valid = checkdnsrr($domain[1], "ANY");

    if($valid) 
      echo "The domain exists!";
    else 
      echo "Cannot locate MX record for $domain[1]!";
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Development »




Environment
Error
Hash
Include
Locale
Math
Network
Output
Reflection
PHP Regular Expressions