Forum Moderators: coopster

Message Too Old, No Replies

checkdnsrr doesn't work for all?

         

jackvull

11:08 am on Jun 30, 2006 (gmt 0)

10+ Year Member



Hi
I use these 2 functions to check for correct email addresses.
However, I have put in a few email addresses that I know exist and work and the functions return false.
Any ideas on why this might happen? Should I be checking records other than MX?

function validateEmailOnLinux($email)
{
// take a given email address and split it into the
// username and domain.
list($userName, $mailDomain) = split("@", $email);
$flag = checkdnsrr($mailDomain.'.', "MX");
return $flag;
}

function validateEmailOnWindows($email)
{
list($userName, $hostName) = split("@", $email);
$recType = '';
if(!empty($hostName)) {
if( $recType == '' ) $recType = "MX";
exec("nslookup -type=$recType $hostName".'.', $result);
// check each line to find the one that starts with the host
// name. If it exists then the function succeeded.
foreach ($result as $line) {
if(eregi("^$hostName",$line)) {
return true;
}
}
// otherwise there was no mail handler for the domain
return false;
}
return false;
}

Romeo

12:07 pm on Jun 30, 2006 (gmt 0)

10+ Year Member



The SMTP mail stuff works on MX records, if MX records are there. If no MX record can be found, a domain's A record will be tried.

Kind regards,
R.

eeek

7:43 pm on Jun 30, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This will also fail with temporary DNS outages. Do you really want to reject the user because you can't reach his DNS server?

jackvull

9:23 am on Jul 1, 2006 (gmt 0)

10+ Year Member



So, you recommend just using a regular expression or something and perhaps validating their address via a return email?

eeek

11:35 am on Jul 1, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes, verify by actually sending an email.