Email Address Validation in php

By | February 7, 2015

Easily Email Address Validation in php

How you gave easily  Validation to your email address in php .

i talk about two ways to  set email Validation…

simple validation

$email = ‘’;
$validation = filter_var($email, FILTER_VALIDATE_EMAIL);
if ( $validation ) $output = ‘proper email address’;
else $output = ‘wrong email address’;
echo $output;

Advanced validation


if (isValidEmail($email))
 echo “Hooray! Adress is correct.”;
 echo “Sorry! No way.”;

function isValidEmail($email)
  //Perform a basic syntax-Check
  //If this check fails, there’s no need to continue
 if(!filter_var($email, FILTER_VALIDATE_EMAIL))
 return false;

//extract host
 list($user, $host) = explode(“@”, $email);
   //check, if host is accessible
 if (!checkdnsrr($host, “MX”) && !checkdnsrr($host, “A”))
 return false;

return true;


Category: PHP

Leave a Reply

Your email address will not be published. Required fields are marked *