kgaughan (owner)

Revisions

gist: 30779 Download_button fork
public
Public Clone URL: git://gist.github.com/30779.git
Embed All Files: show embed
Checking if a host can receive mail. #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function can_host_receive_mail($host) {
    if (checkdnsrr($host, 'MX')) {
        return true;
    }
    // We try the host itself if it exists no MX records were found, as per
    // RFC2821.
    if (checkdnsrr($host, 'A') || checkdnsrr($host, 'AAAA')) {
        $h = @fsockopen($host, 25, $errno, $errstr, 30);
        if ($h) {
            fclose($h);
            return true;
        }
    }
    return false;
}