simple php email validation function

Ian Landsman • November 29, 2004

Surprisingly there arn't many email validation functions I like out there so I whipped this up. No fancy checking of mx records just a straight syntax check of an email address in PHP. Returns 0 or 1.



function validateEmail($email){
$pattern = '/^w[wd]+(.[wd]+)*@w[wd]+(.[wd]+)*.[a-z]{2,7}$/i';
return preg_match($pattern,$email);
}