Move to data-driven decision making with my new NPS survey software.

All my readers receive 10% off for life with code: ian

simple php email validation function

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);
}
→ Share your thoughts with me on Twitter
Stay In The Loop

I won't bother you with short posts or off topic musings. You'll also receive my ebook on enterprise sales for bootstrappers for free.