English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP getmxrr() Function Usage and Example

PHP HTTP Reference Manual

The getmxrr() function retrieves the MX records corresponding to an Internet hostname

Syntax

bool getmxrr ( string $hostname , array &$mxhosts [, array &$weight ] )

Definition and Usage

 Search for the MX DNS record corresponding to hostname.

Return Value

If a record is found, it will return True, otherwise it will return false

Online Example

Try the following example

<?php
   getmxrr("baidu.com", $mx_records, $mx_weight);
   for($i = 0; $i < count($mx_records); $i++){
      $mxs[$mx_records[$i]] = $mx_weight[$i];
   }
   asort($mxs);
   $records = array_keys($mxs);
   for($i = 0; $i < count($records); $i++){
      echo $records[$i];
      echo '<br/>';
   }
?>

The above example produces the following results

mx.maillb.baidu.com
mx.n.shifen.com
mx1.baidu.com
jpmx.baidu.com
mx50.baidu.com

PHP HTTP Reference Manual