PHP Function Reference

PHP getmxrr() Function

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


getmxrr(hostname, mxhosts, weights)


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.


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


//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 => 
1 => 
2 => 
3 => 
4 => 

❮ PHP Network Reference