$hostname = "google.com";
if(dns_get_mx($hostname, $mxhosts, $weights)) {
foreach($mxhosts as $key => $host) {
echo "Hostname: $host (Weight: {$weights[$key]}
\n";
}
} else {
echo "Could not find any MX records for $hostname\n";
}
?>