3

If anyone knows how can we detect fake domain names of email addresses, it would be a great help.

Note, that I don't want to validate an email. I want to know if the email domain name exists or not.

Luci
  • 3,174
  • 7
  • 31
  • 36
  • So something like an NSLOOKUP isn't possible? or http://php.net/gethostbyaddr – Mark Baker Dec 06 '13 at 10:58
  • 2
    The domain could exist but the email address itself couldn't.. what's the use of only checking the domain? – Ali Dec 06 '13 at 10:58
  • https://www.google.com/search?q=whois+api&rlz=1C1GGGE_ruUA538UA538&oq=whois+api&aqs=chrome..69i57j0l5.4059j0j7&sourceid=chrome&espv=210&es_sm=93&ie=UTF-8 – paka Dec 06 '13 at 10:59
  • @AliTrixx, you are right, but at least if i can detect the domain if fake or not, I can avoid much spam users. – Luci Dec 06 '13 at 11:03

1 Answers1

2

in php there is a function checkdnsrr

How do you check if a domain name exists?

if (checkdnsrr('test.nl', 'A')) // or use ANY or for other see above link
{
    echo 'Domain exists';
}
else 
{ 
    echo 'Domain does not exist'; 
} 

------------------ Code that is working -------

 <?php 

if (checkdnsrr('google.com', 'A')) // or use ANY or for other see above link
{
    echo 'Domain exists';
}
else 
{ 
    echo 'Domain does not exist'; 
}

?>
//Output = Domain exists

//

if (checkdnsrr('fakewebtesting.com', 'A')) // or use ANY or for other see above link
{
    echo 'Domain exists';
}
else 
{ 
    echo 'Domain does not exist'; 
}

?>
  //Output = Domain does not exists

I hope you are extracting domain name from email and using it in this function.

Docs link:

http://php.net/manual/en/function.checkdnsrr.php

Community
  • 1
  • 1
Maz I
  • 3,664
  • 2
  • 23
  • 38
  • Whatever I'm trying it says domain exists. It does not seem to help me. – Luci Dec 06 '13 at 11:30
  • I tried and it give me exact. can you please post some code you are using – Maz I Dec 06 '13 at 11:38
  • I tried your sample. It gave me exactly this: Domain existsDomain exists – Luci Dec 06 '13 at 12:42
  • working for me again here. Can you please post you code here i can test it. – Maz I Dec 06 '13 at 13:24
  • which version of PHP are you using? and on Windows or Linux because change log says that : 5.3.0 This function is now available on Windows platforms. – Maz I Dec 06 '13 at 13:25
  • try this code as well. getmxrr ('yahoo.com', $out); print_r($out); $a = checkdnsrr('yahoo.com', 'MX'); var_dump($a); – Maz I Dec 06 '13 at 13:28
  • or check this http://stackoverflow.com/questions/15195396/checkdnsrr-returns-wrong-info – Maz I Dec 06 '13 at 13:31