如何使用getmxrr获取邮件服务器的主机名、ip地址


How to use getmxrr to get the host name, ip address of mail server?

在php手册中,getmxrr(get-mx记录)是一个布尔值,如果该记录存在,则为true。

然而,我想获得更多关于邮件域的信息,例如:

一个简单的mx查找记录(hotmail)是这样的:

Pref    Hostname    IP Address  TTL     
5   mx1.hotmail.com 65.55.92.152    60 min  
5   mx2.hotmail.com 65.55.92.152    60 min  
5   mx3.hotmail.com 65.54.188.110   60 min  
5   mx4.hotmail.com 65.55.92.136    60 min  

我可以使用getmxrr获得上述信息吗?

谢谢。

第二个参数给出mx主机列表:

$hosts = array();
getmxrr('hotmail.com', $hosts);
var_dump($hosts);

getmxrr

以gethostbyname 获取和ip地址的简单请求

 foreach($hosts as $host) {
     echo $host . ' ' . gethostbyname($host) . '<br />';
 }