This is an archival post from my newsletter. Join the newsletter to get in the loop.

Simple PHP Email Validation Function

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]+)[email protected][wd]+(.[wd]+)*.[a-z]{2,7}$/i';
return preg_match($pattern,$email);
[cm_simple_form id=3]