note 16368 deleted from function.ereg by jimw

From: Date: Sat, 27 Oct 2001 21:39:26 +0000
Subject: note 16368 deleted from function.ereg by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-19513@lists.php.net to get a copy of this message
All the e-mail validation functions will return info@info.info as an invalid e-mail address. All of the functions check the number of characters after the last dot, and it can be 2 or 3 and here it's 4 :) Here's the tweaked function: function is_validEmail($email) { if (eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$", $email, $check)) { if ( getmxrr(substr(strstr($check[0], '@'), 1), $validate_email_temp) ) { return TRUE; } // THIS WILL CATCH DNSs THAT ARE NOT MX. if(checkdnsrr(substr(strstr($check[0], '@'), 1),"ANY")){ return TRUE; } } return FALSE; } or the Windows version (where DNS functions don't work): function is_validEmail($email) { if (eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$", $email, $check)) return TRUE; return FALSE; } Cheers everybody! Saveli.

« previous php.notes (#19513) next »