getMessage() !== 'dns_get_record(): A temporary server error occurred.') { throw $e; } $mx_records = false; } return $hosts; } function get_a_hosts($domain) { $hosts = array(); $a_records = dns_get_record($domain, DNS_A); foreach ($a_records as $a_record) { $hosts[] = $a_record['ip']; } $a_records = dns_get_record($domain, DNS_AAAA); foreach ($a_records as $a_record) { $hosts[] = $a_record['ipv6']; } return $hosts; } function get_outgoing_hosts_best_guess($domain) { // try the SPF record to get hosts that are allowed to send outgoing mails for this domain $hosts = get_spf_allowed_hosts($domain); if ($hosts) return $hosts; // try the MX record to get mail servers for this domain $hosts = get_mx_hosts($domain); if ($hosts) return $hosts; // fall back to the A record to get the host name for this domain return get_a_hosts($domain); } ?>