title: Email validation error in PHP
body: <p>I have build up a form and and link a <code>emailvalidation.php</code> to send the data on my mail. I am facing an error in my PHP code on line 37. I don't know where is the error.</p>
  
  <blockquote>
    <p>Error: Fatal error: Call to undefined function <code>checkdnsrr()</code> in <code>G:\PleskVhosts\domain.com\httpdocs\php\functions\emailValidation.php</code> on line 37 </p>
  </blockquote>
  
  <p>PHP code:</p>
  
  <pre><code>&lt;?php
  function validEmail($emailaddress) {
      $isValid = true;
      $atIndex = strrpos($emailaddress, "@");
      if (is_bool($atIndex) &amp;&amp; !$atIndex) {
          $isValid = false;
      } else {
          $domain = substr($emailaddress, $atIndex + 1);
          $local = substr($emailaddress, 0, $atIndex);
          $localLen = strlen($local);
          $domainLen = strlen($domain);
          if ($localLen &lt; 1 || $localLen &gt; 64) {
              // local part length exceeded
              $isValid = false;
          } else if ($domainLen &lt; 1 || $domainLen &gt; 255) {
              // domain part length exceeded
              $isValid = false;
          } else if ($local[0] == '.' || $local[$localLen - 1] == '.') {
              // local part starts or ends with '.'
              $isValid = false;
          } else if (preg_match('/\\.\\./', $local)) {
              // local part has two consecutive dots
              $isValid = false;
          } else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) {
              // character not valid in domain part
              $isValid = false;
          } else if (preg_match('/\\.\\./', $domain)) {
              // domain part has two consecutive dots
              $isValid = false;
          } else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&amp;`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\", "", $local))) {
              // character not valid in local part unless
              // local part is quoted
              if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\", "", $local))) {
                  $isValid = false;
              }
          }
          if ($isValid &amp;&amp; !(checkdnsrr($domain, "MX") || checkdnsrr($domain, "A"))) {
              // domain not found in DNS
              $isValid = false;
          }
      }
      return $isValid;
  }
  ?&gt;
  </code></pre>