PHP window Platform simulation CHECKDNSRR function to detect whether the email is real

Source: Internet
Author: User

In PHP, there is a CHECKDNSRR function in the system function that checks whether it has a DNS record based on a given host name (domain name) or IP address, in order to verify that it is real. However, this function can only be used under Linux systems and does not support Windows platforms. The following is a collection of online hack method, the implementation of the window platform simulation CHECKDNSRR function to detect the existence of an email function!

if (!function_exists (' CHECKDNSRR ')) {
    function checkdnsrr ($host, $type = ') {
        if (!empty ($host)) {
            $type = ( Empty ($type))? ' MX ': $type;
            EXEC (' nslookup-type= '. $type. " '. Escapeshellcmd ($host), $result);
            $it =new Arrayiterator ($result);
            foreach (New Regexiterator ($it, ' ~^ '. $host. ~ ', Regexiterator::get_match) as $result) {
                if ($result) {return
                    true;
                }
        }} return false;
    }
}

Next I'll introduce the parameters of the function:

BOOL CHECKDNSRR (String $host [, String $type = "MX"])

The first parameter we will not say, is the domain name or IP

The second parameter is the resolution type, respectively:

A (address) record is a record of IP addresses for the specified host name (or domain name).

MX record is the specified mail exchange record (default)

The NS record is a record of the specified domain name server, specifying which DNS the domain name will be parsed by.

SOA records are typically used in a secondary DNS server to specify who is the primary server.

The reverse parsing record of the PTR record from the IP point to the domain name

CNAME record alias record

AAAA record is a record pointing to IPv6

A6 Record ditto

The SRV record is the type of resource record that is supported in the DNS server's database and is typically applied to Microsoft's Active Directory settings.

TXT record text information

Any records, all data types

Articles that you may be interested in

    • How PHP uses the filter function to verify mailboxes, URLs, and IP addresses
    • PHP Gets the function of the first letter of Chinese pinyin (really can be used)
    • Sphinx installed using Windows [support Chinese Full-text Search]
    • PHP judgment function, class, class method exists
    • PHP uses the Session_set_save_handler () function to save session to MySQL database
    • Master-Slave synchronous backup steps of MySQL database in Windows environment
    • A program in which PHP gets all the files in the directory and saves the results to an array
    • PHP Analog get_headers function


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.