Software Development Kit

cPanel & WHM's API [+] cPanel & WHM's API [-]


Modules and Plugins [+] Modules and Plugins [-]


cPanel & WHM Hooks [+] cPanel & WHM Hooks [-]


cPAddons (Site Software) [+] cPAddons (Site Software) [-]


System Administration [+] System Administration [-]


Developer Software [+] Developer Software [-]


Back to All Documentation

List a Domain's MX Records — listmxs

This function is only available in version 11.27/11.28+.

This function will list a specified domain's MX records.

Calling Functions

Using the XML API

To use the XML API to perform the listmxs function from within your custom script:

  • Append the /xml-api/listmxs function call name, plus the required variables (see below), to a URL which includes the address of your server.

  • For example, on a server whose hostname is example.com, you would include the following string in your script: https://example.com:2087/xml-api/listmxs

  • You need to be logged in with the proper permissions in order to call a function. See our document about Authenticating API Function Calls for more information about authenticating APIs from within a script.

  • You can also perform the function by entering the string in your web browser's address bar. This may be useful for testing the function call and viewing its output.

Using the JSON API

To use the JSON API to perform the listmxs function from within your custom script:

  • Append the /json-api/listmxs function call name, plus the required variables (see below), to a URL which includes the address of your server.

  • For example, on a server whose hostname is example.com, you would include the following string in your script: https://example.com:2087/json-api/listmxs

  • You need to be logged in with the proper permissions in order to call a function. See our document about Authenticating API Function Calls for more information about authenticating APIs from within a script.

  • You can also perform the function by entering the string in your web browser's address bar. This may be useful for testing the function call and viewing its output.

Variables

Input

The following input variables are required:

  • api.version (integer) — The XML API version number. You should always set this value to 1.
  • domain (string) — The domain corresponding to the MX records that you wish to view.

Output

  • result — Root-level XML tag for the output of the listmxs function.
    • data — The data container for the function's results.
      • record — The container for a specific MX record.
        • Line (integer) — The line number of the MX record, from within the zone file.
        • ttl (string) — The record's time to live.
        • class (string) — The class of the record.
        • exchange (string) — The exchanger to which the domain will point. (e.g. example.com)
        • preference (integer) — The MX record's preference value.
        • type (string) — The type of record you are viewing.
        • name (string) — The name of the record.
    • metadata — The metadata results container.
      • result (boolean) — A boolean value that indicates success or failure.
        • 1 — success.
        • 0 — failure.
      • reason (string) — A string value that contains a message of success or a reason for failure.
      • version (integer) — The XML API version number, 1 in this case.
      • command (string) — The function that has just run, listmxs in this case.

Examples

XML API

Calling https:example.com:2087/xml-api/listmxs?api.version=1&domain=example.com in WebHost Manager will produce results similar to:

<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>

JSON API

Calling https:example.com:2087/json-api/listmxs?api.version=1&domain=example.com in WebHost Manager will produce results similar to:

{
   "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"
   }
}

Topic revision: r6 - 30 Sep 2011 - 15:17:30 - Main.JustinSchaefer
AllDocumentation/AutomationIntegration.XmlListMxs moved from Sandbox.XmlListMxs on 02 Sep 2010 - 19:23 by Main.JustinSchaefer