note 93591 deleted from function.preg-match by danbrown

From: Date: Thu, 17 Sep 2009 14:55:56 +0000
Subject: note 93591 deleted from function.preg-match by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-160792@lists.php.net to get a copy of this message
Note Submitter: RPaseur at NationalPres dot org ---- // A FUNCTION TO TEST FOR A VALID EMAIL ADDRESS, RETURN TRUE OR FALSE function check_valid_email($email) { // IF PHP 5.2 OR ABOVE, WE CAN USE THE FILTER // MAN PAGE: http://us3.php.net/manual/en/intro.filter.php if (strnatcmp(phpversion(),'5.2') >= 0) { if(filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE) return FALSE; } else { $regex = '/^[A-Z0-9_-][A-Z0-9._-]*@([A-Z0-9][A-Z0-9-]*\.)+[A-Z]{2,6}$/i'; if (!preg_match($regex, $email)) return FALSE; } // FILTER or PREG DOES NOT TEST IF THE DOMAIN OF THE EMAIL ADDRESS IS ROUTABLE $domain = explode('@', $email); if ( checkdnsrr($domain[1],"MX") || checkdnsrr($domain[1],"A") ) return TRUE; // EMAIL NOT ROUTABLE return FALSE; }

« previous php.notes (#160792) next »