note 8437 added to ereg

From: Date: Wed, 13 Sep 2000 02:17:53 +0000
Subject: note 8437 added to ereg
Groups: php.notes 
Request: Send a blank email to php-notes+get-4785@lists.php.net to get a copy of this message
Again about testing for valid emails... Using methods described above, namely the one from r.garcia@netia.net for checking the email and the tstrum@salter.com for using getmxrr(), I composed this modified function below. Please not that getmxrr() will not properly work with people at my host, boas.anthro.mnsu.edu. I don't know why, but the getmxrr() fails, and I know I set up accounts on this machine. Also, it now checks for .mil and .arpa. You'll need to modify this when the new top-level domains are added (early 2001, I think). This function also has slightly stricter checking than the ones before. function valid_email ($email) { if (eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-wyz][a-z](g|l|m|pa|t|u|v)?$", $email, $check)) { // return TRUE; // I return TRUE here since getmxrr() doesn't work well for me if (getmxrr(substr(strstr($email, '@'), 1), $hosts_found)) { return TRUE; } } return FALSE; } http://www.php.net/manual/function.ereg.php

« previous php.notes (#4785) next »