Re: Checking for a Valid Email String.
| From: | Paul Chvostek | Date: | Wed, 12 Mar 2003 01:37:16 +0000 |
| Subject: | Re: Checking for a Valid Email String. | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-139203@lists.php.net to get a copy of this message | ||
> On Wed, 12 Mar 2003, Philip J. Newman wrote:
>
> > Required: Help for checking for a valid email string.
On Tue, Mar 11, 2003 at 08:19:36PM -0500, David E.S.V. wrote:
>
> you mean something like this?
>
> //checking if the email is valid
>
> if (eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$",
> $email, $check))
> {
> if ( !getmxrr(substr(strstr($check[0], '@'), 1), $validate_email_temp) )
> $mensaje="server not valid";
>
> // checking DNS
> if(!checkdnsrr(substr(strstr($check[0], '@'), 1),"ANY"))
> $mensaje="server not valid";
>
> }
Don't forget plus signs. When providing email addresses to lists and
web sites, I regularly tag my address (as the From address on this
message demonstrates). Using procmail for local delivery allows these
addresses to be delivered to my account, and I can more easily track
down the origin of "tagged" spam. When I come across a web site or list
that doesn't allow my address with a plus sign, I find another site or
list. So I use:
function isvalidemail($what) {
if (!eregi('[a-z0-9][a-z0-9._=+-]*@([a-z0-9][a-z0-9-]*\.)+[a-z][a-z]+$',$what))
return(false);
list($user,$domain) = explode("@",$what);
if (!getmxrr($domain,$mxhosts)) return(false);
if (!count($mxhosts) > 0) return(false);
return(true);
}
--
Paul Chvostek <paul@it.ca>
Operations / Abuse / Whatever
it.canada, hosting and development http://www.it.ca/