note 4760 deleted from ereg by jmoore
| From: | jmoore@php.net | Date: | Wed, 14 Feb 2001 20:13:20 +0000 |
| Subject: | note 4760 deleted from ereg by jmoore | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-11075@lists.php.net to get a copy of this message | ||
Checking emails:
<pre>
function verifyemail ($email) {
if (eregi("^[_.0-9a-z-]+@([0-9a-z][-0-9a-z.]+).([a-z]{2,3}$)", $email, $check)) {
if (getmxrr($check[1].".".$check[2],$temp)) {
return true;
}
return false;
} else {
return false;
}
}
</pre>
verifyemail("user@triple-bypass.com"); // TRUE
verifyemail("user@salter.com"); // TRUE
verifyemail("user@ns.sympatico.ca"); // TRUE
verifyemail("user@ns.symfdsfdspatico.ca"); // FALSE
This seems to work best for me. It's hacked together from some buggy script (or script I
couldn't get to work anyway) from the notes on the "mail" page.
I'm not much of a person for regular expressions but this seems to work 100% on all the domains
I tested it on. I'd appreciate an email (with explanation) if there's somethign wrong with
the regex used here (or a way it could be better).