Re: validating email address
| From: | Terence | Date: | Thu, 04 Dec 2003 04:24:51 +0000 |
| Subject: | Re: validating email address | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-171771@lists.php.net to get a copy of this message | ||
You could use MX records if you wanted to. I found this some time ago...
function checkEmail($Email) {
//Do the basic Reg Exp Matching for simple validation
if (eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $Email)) {
return FALSE;
}
//split the Email Up for Server validation
list($Username, $Domain) = split("@",$Email);
//If you get an mx record then this is a valid email domain
if(getmxrr($Domain, $MXHost)) {
return TRUE;
}
else {
//else use the domain given to try and connect on port 25
//if you can connect then it's a valid domain and that's good enough
if(fsockopen($Domain, 25, $errno, $errstr, 30)) {
return TRUE;
}
else {
return FALSE;
}
}
}
----- Original Message -----
From: "Blake Schroeder" <blake@lhwd.net>
To: <php-general@lists.php.net>
Sent: Thursday, December 04, 2003 2:31 AM
Subject: [PHP] validating email address
Whats the best way to validate email address (check for white space,
check for .com, .net.edu etc)
-Blake
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php