RE: [PHP] Email validation
| From: | Jason Murray | Date: | Wed, 21 Mar 2001 04:27:56 +0000 |
| Subject: | RE: [PHP] Email validation | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-44873@lists.php.net to get a copy of this message | ||
> Can anyone tell me what the best form of Email validation
> there is? It needs to be quick & as open to - and . as possible.
We use this one on www.inww.com:
<?
Function validEmail($emailaddress)
{
// Decides if the email address is valid. Checks syntax and MX records,
// for total smartass value. Returns "valid", "invalid-mx" or
// "invalid-form".
// Validates the email address. I guess it works. *shrug*
if
(eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$",
$emailaddress, $check))
{
//if ( getmxrr(substr(strstr($check[0], '@'), 1),
$validate_email_temp) )
if ( checkdnsrr(substr(strstr($check[0], '@'), 1), "ANY") )
{ return "valid"; }
else
{ return "invalid-mx"; }
}
else
{
return "invalid-form";
}
}
?>
Jason
--
Jason Murray
jasonm@melbourneit.com.au
Web Design Team, Melbourne IT
Fetch the comfy chair!