Re: [PHP] email validation (no regex)

2005-09-21 Thread cron


As an admin I would assume this as spammers trying to get some emails and I 
would block this on the firewall.



- Original Message - 
From: "Michael Sims" <[EMAIL PROTECTED]>

To: 
Sent: Wednesday, September 21, 2005 4:22 PM
Subject: RE: [PHP] email validation (no regex)



Jim Moseby wrote:

There's no requirement for an MX-record, so you'd need to check the
A-record ($domain) too.


Excellent answer.  No requirement for MX record?

[showing my ignorance]
How does email routing happen if there is no mail exchanger in the
zonefile for a particular domain?
[/ignorance]


Most all mail transfer agents will fall back to looking for an A record if 
an MX
record doesn't exist.  It's good practice to define an MX record but it 
isn't

required...

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] email validation (no regex)

2005-09-21 Thread Michael Sims
Jim Moseby wrote:
>> There's no requirement for an MX-record, so you'd need to check the
>> A-record ($domain) too.
>
> Excellent answer.  No requirement for MX record?
>
> [showing my ignorance]
> How does email routing happen if there is no mail exchanger in the
> zonefile for a particular domain?
> [/ignorance]

Most all mail transfer agents will fall back to looking for an A record if an MX
record doesn't exist.  It's good practice to define an MX record but it isn't
required...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



FW: [PHP] email validation (no regex)

2005-09-21 Thread Jim Moseby

(private email forwarded to list)
-Original Message-
From: [EMAIL PROTECTED]
Sent: Wednesday, September 21, 2005 2:19 PM
To: Jim Moseby
Subject: Re: [PHP] email validation (no regex)


There's no requirement for an MX-record, so you'd need to check the
A-record ($domain) too.

This approach is likely extremely resource and time intensive. So, in
my view, not something that you'd really want to do while the user is
"holding on the line".

  - Rick

-- End Original Message --

Excellent answer.  No requirement for MX record?
  
[showing my ignorance] 
How does email routing happen if there is no mail exchanger in the zonefile
for a particular domain? 
[/ignorance]

"Time and resource intensive" is the only down-side I have been able to
think of.  Even though it should run very quickly, I have no control over
internet lag, load on the SMTP server, etc.  Doing it this way places all
those variables out of my control. A definate downside.

JM

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] email validation (no regex)

2005-09-21 Thread Jim Moseby
I threw together this totally untested and unreliable code to solicit
comments on whether or not this is a good way to validate emails.  Consider
the following:



function validate_email($email){
  if (str_word_count($email,'@')!=1){return('Not a proper email address');}
  $parts=explode('@',$email);
  $name=$parts[0];
  $domain=$parts[1];
  $mxconnect=FALSE;
  if (!getmxrr($domain,$mxhosts)){
return('Invalid domain');
  }//if
  foreach($mxhosts as $mxhost){
if($fp=fsockopen($mxhost,25)){
  $mxconnect=TRUE;
  fwrite($fp,"EHLO test");
  $response=fread($fp,256);
  fwrite($fp, "Mail From: [EMAIL PROTECTED]".chr(13));
  $response=fread($fp,256);
  fwrite($fp, 'RCPT To: '.$email.chr(13));
  $response=fread($fp,256);
  $parts=explode(' ',$response);
  if ($parts[0]!='250'){
fwrite($fp,'QUIT'.chr(13));
fclose($fp);
return('Unknown Recipient');
  }//if
}//if
  }//foreach
  if (!$mxconnect){return('Could not connect to MX');}
  fwrite($fp,'QUIT'.chr(13));
  fclose($fp);
  return('OK');
}//function validate_email



So, what is the general thought about validating email addresses in this
manner?

JM

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php