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

Join my mailing list

Join my mailing list and get a copy of my ebook, Securing the Five Figure Sale, for free. Instantly.