Forum Moderators: coopster
if (eregi("^([a-z]¦[0-9]¦\.¦-¦_)+@([a-z]¦[0-9]¦\.¦-¦_)+\.([a-z]¦[0-9]){2,3}$", $_REQUEST['email']) &&
!eregi("(@.*@)¦(\.\.)¦(@\.)¦(\.@)¦(^\.)", $_REQUEST['email']))
Now I`ve got some clown who keeps emailing me with a dud address and he wants to know why I`m not replying. Needles to say I can`t reply.
The address being used is something like:
www.blahblah@yahoo.com
Can you suggest a slight adjustment to the above code that will generate an error if the e-mail starts www.
Thanks
:)
[zend.com...]
WBF
If it fails (even before that step), you can judge by the error you get.
- wrong host
- no mail server
- no response (that one kills interactivity)
- no such mailbox (that's the best one of all)
- over quota
...
And base your response page on that data.
This is the function I use, which checks against the DNS records for a valid mail exchanger in addition to verifying the email address:
function isvalidemail( $email )
{
if (eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$", $email, $check))
{
if (getmxrr( substr(strstr($check[0], '@'), 1),$mxhosts))
{
return true;
}
}
return false;
}
If you want to trap that specifically you'll need a special case.
I now wrote one that does an NS Query. You really only care about the domain since anything before the @ sign _could_ be valid for the receiving mail server (even if it may break rfc).
It is important to check both getmxrr and gethostbyname since many mail servers do not have MX records (which I beleive is valid if not strange) in such cases you deliver to the IP of the A record for the domain.
function CheckEmail ($email) {
list($username,$domain)=explode("@",$email);
if( getmxrr( $domain, $mxhosts ) == FALSE && gethostbyname($domain) == $domain ) {
return FALSE;
} else {
return TRUE;
}
}