$parts = parse_url($url); $host = $parts['host']; # Find MX record to use for SURBL $pieces = explode('.', $host); $mx_found = 0; for ($i = 2; $i <= count($pieces); $i++) { $possible_domain = implode('.', array_slice($pieces, -$i)); if (!checkdnsrr($possible_domain, 'MX')) { continue; } else { $mx_found++; break; } } # Reject domains without MX if (!$mx_found) { return "NOMX"; } # Check SURBL if (checkdnsrr("$possible_domain.multi.surbl.org", 'A')) { return "SURBL"; }