note 4729 deleted from function.mail by jimw
| From: | jimw@php.net | Date: | Wed, 31 Oct 2001 22:59:32 +0000 |
| Subject: | note 4729 deleted from function.mail by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-19850@lists.php.net to get a copy of this message | ||
OK, I was totally confused about the email validation code snippits from above. In my testing both
were buggy. The following code seems to work perfectly well for the domains I listed below in the
function calls. This includes hyphenated domains.
<pre>
function checkmail ($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 "Valid - ".$check[1].".".$check[2]."<br>";
}
return "No MX for " . $check[1].".".$check[2]."<br>";
} else {
return "Badly formed address.<br>";
}
}
echo checkmail("user@triple-bypass.com");
echo checkmail("user@salter.com");
echo checkmail("user@ns.sympatico.ca");
</pre>