Child pages
  • WHM API 1 Functions - listmxs
Skip to end of metadata
Go to start of metadata

Description

This function lists a domain's MX records.

Important:

In cPanel & WHM version 76 and later, when you disable the DNS role, the system disables this function. For more information, read our How to Use Server Profiles documentation.

Examples 


 JSON API
https://hostname.example.com:2087/cpsess##########/json-api/listmxs?api.version=1&domain=example.com
 XML API
https://hostname.example.com:2087/cpsess##########/xml-api/listmxs?api.version=1&domain=example.com
 Command Line
whmapi1 listmxs domain=example.com


Notes:

  • You must URI-encode values.
  • For more information and additional output options, read our Guide to WHM API 1 documentation or run the whmapi1 --help command.
  • If you run CloudLinux™, you must use the full path of the whmapi1 command:

    /usr/local/cpanel/bin/whmapi1

 Output (JSON)
{
   "data":{
      "record":[
         {
            "Line":"21",
            "ttl":"14400",
            "class":"IN",
            "exchange":"mx1.example.com",
            "preference":"0",
            "type":"MX",
            "name":"example.com."
         },
         {
            "Line":"28",
            "ttl":"14400",
            "class":"IN",
            "exchange":"mx2.example.com",
            "preference":"20",
            "type":"MX",
            "name":"example.com.example.com."
         }
      ]
   },
   "metadata":{
      "result":1,
      "reason":"Records obtained.",
      "version":1,
      "command":"listmxs"
   }
}
 Output (XML)
<result>
    <data>
        <record>
            <Line>21</Line>
            <ttl>14400</ttl>
            <class>IN</class>
            <exchange>mx1.example.com</exchange>
            <preference>0</preference>
            <type>MX</type>
            <name>example.com.</name>
        </record>
        <record>
            <Line>28</Line>
            <ttl>14400</ttl>
            <class>IN</class>
            <exchange>mx2.example.com</exchange>
            <preference>20</preference>
            <type>MX</type>
            <name>example.com</name>
        </record>
    </data>
    <metadata>
        <result>1</result>
        <reason>Records obtained.</reason>
        <version>1</version>
        <command>listmxs</command>
    </metadata>
</result>


Note:

Use WHM's API Shell interface (WHM >> Home >> Development >> API Shell) to directly test WHM API calls.

Parameters

ParameterTypeDescriptionPossible valuesExample

domain

string

Required

The zone record's domain.

A valid domain name on the server.example.com

Returns

ReturnTypeDescriptionPossible valuesExample

record

array of hashesAn array of zone record data hashes.

This array of hashes includes the name, Line, class, ttl, type, exchange, and preference returns.

 

name

string

The record's name.

The function returns this value in the record array.

A valid domain name or hostname.

hostname.example.com

Line

integer

The zone record's line number.

The function returns this value in the record array.

A positive integer.1

class

string

The record's class.

The function returns this value in the record array.

  • IN
  • Very rarely, another valid DNS record class.

IN

ttl

integer

The record's Time To Live (TTL).

The function returns this value in the record array.

A positive integer that represents the TTL, in seconds.

86400

type

string

The DNS record's type.

The function returns this value in the record array.

MX is the only possible value.

MX

exchange

string

The domain's mail exchanger.

The function returns this value in the record array.

A valid mail exchanger.mail.example.com

preference

integer

The MX record's priority order.

The function returns this value in the record array.

An integer that represents the record's priority order.

Note:

Lower values indicate a higher priority order. 

20