PHP Function Reference

PHP getmxrr() Function



The PHP getmxrr() function returns MX records corresponding to the specified internet host name.

Syntax

getmxrr(hostname, mxhosts, weights)

Parameters

hostname Required. Specify the Internet host name.
mxhosts Required. A list of the MX records found is placed into the array mxhosts.
weights Optional. If the weights array is provided, it will be filled with the weight information gathered.

Return Value

Returns true if any records are found. Returns false if no records were found or if an error occurred.

Example:

The example below shows the usage of getmxrr() function.

<?php
$domain="alphacodingskills.com";

//getting the MX records
if(getmxrr($domain, $mx_details)){
  foreach($mx_details as $key => $value){
    echo "$key => $value \n";
  }
}
?>

The output of the above code will be:

0 => alt4.aspmx.l.google.com 
1 => alt2.aspmx.l.google.com 
2 => alt1.aspmx.l.google.com 
3 => aspmx.l.google.com 
4 => alt3.aspmx.l.google.com 

❮ PHP Network Reference

5