PHP window Platform simulation CHECKDNSRR function to detect if email is real _php tutorial

Source: Internet
Author: User
Tags domain name server mail exchange mx record to domain
In PHP's system functions, there is a CHECKDNSRR function that checks whether it has a DNS record based on a given host name (domain name) or IP address to verify that it exists. However, this function can only be used under Linux systems and does not support the Windows platform. The following is an online collection of a hack method, the implementation of the window platform to simulate the 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;    }}

Let me now 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 parse type, respectively:

A (address) record is the IP address record that corresponds to the specified hostname (or domain name).

MX record is a specified mail exchange record (default)

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

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

PTR records reverse parsing records from IP to domain name

CNAME record alias record

AAAA record is a record pointing to IPv6

A6 Record Ibid.

SRV records It is a 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 any records, all data types

Articles you may be interested in

    • Php method for verifying mailboxes, URLs, and IP addresses using the filter function
    • PHP to get the first letter of Chinese pinyin function (really can use)
    • Sphinx installation under Windows [Support Chinese full text Search]
    • PHP judgment function, class, class method exists
    • PHP Simulation get_headers function
    • PHP gets all the files in the directory and saves the results to an array of programs
    • Master-Slave synchronous backup steps for MySQL database in Windows environment
    • JS Common function Collection (remove space, verify mailbox, date, positive integer, etc.)

http://www.bkjia.com/PHPjc/813353.html www.bkjia.com true http://www.bkjia.com/PHPjc/813353.html techarticle in the PHP system function, there is a CHECKDNSRR function, the function is to check whether it has a DNS record based on a given host name (domain name) or IP address, to verify that it is ...

  • 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.