RE: [PHP-DB] E-mail address verification

From: Date: Thu, 20 Jun 2002 15:59:44 +0000
Subject: RE: [PHP-DB] E-mail address verification
Groups: php.db 
Request: Send a blank email to php-db+get-19912@lists.php.net to get a copy of this message
I do it like this: if (eregi("^[a-z0-9]+([\.%!][_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$", $email)) { list($user, $host) = explode("@", $email); if ( !checkdnsrr($host, "MX") ) return TRUE; } else { return FALSE; } } As you can see, the email can "look" right, but domain isn't valid. So you can check DNS record for MX domain. Next step is to connect to mail server and verify user, but usualy that takes time and it's better to send some kind of auth code to that mail and if user conforms it, you can use it... This worked very well. For any of you out there that are looking for a simple verification with host dns lookup, here it is!!! For a more comprehensive "class" check here, thanks to Manuel Lemos http://www.phpclasses.org/emailvalidation

« previous php.db (#19912) next »