The customCheckDnsrr() function is a classical solution for implementing the desired functionality of checkdnsrr() on a Windows platform; it is extensively used across numerous scripts. The code for our new function is as follows:
Our version of the checkdnsrr() function works by making a system call, available in Windows systems, known as nslookup. It resembles the chekdnsrr() functionality, and is very useful for achieving the same results. We make use of the nslookup function by invoking the PHP exec() function, which is one of the several methods for executing a system command in PHP. The result of the command is stored as an array in the $output parameter. When the nslookup function is executed, it searches the corresponding entry in the DNS for the given domain. If the result is successful, the output is similar to the following lines:
To determine whether a proper mail handler for that domain exists, the function iterates over each line of the output by searching for the line that begins with the provided host name. If the line is found, then the function will return true. Otherwise, it will return false. Here’s the code for using our customCheckDnsrr() function:
The snippet is almost identical to the one using checkdnsrr(). It has only been replaced with the customized function, previously defined.
blog comments powered by Disqus |