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

Add an MX Record — savemxs

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

This function will add an MX record.

Calling Functions

Using the XML API

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

  • Append the /xml-api/savemxs 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/savemxs

  • 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 savemxs function from within your custom script:

  • Append the /json-api/savemxs 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/savemxs

  • 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.
  • name (string) — The name of the new MX record.
  • exchange (string) — The exchanger to which the domain will point. (e.g., example.com)
  • preference (integer) — The new MX entry's preference. Lower values indicate a higher preference.

The following input variables are optional:

  • class (string) — The MX record's class.
  • serialnum (integer) — The serial number of the MX record.
  • ttl (integer) — The new record's time to live.

note Note: Input values do not require a trailing dot. However, 'name' is taken literally, meaning that the function will assume that 'name' is a subdomain if no trailing dot is used.

Output

  • result — Root-level XML tag for the output of the savemxs function.
    • 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, savemxs in this case.

Examples

XML API

Calling https:example.com:2087/xml-api/savemxs?api.version=1&domain=example.com&name=mail.example.com&exchange=example.com&preference=10 in WebHost Manager will produce results similar to:

<result>
   <metadata>
      <result>1</result>
      <reason>Bind reloading on server1 using rndc zone: [example.com]</reason>
      <version>1</version>
      <command>savemxs</command>
   </metadata>
</result>

JSON API

Calling https:example.com:2087/json-api/savemxs?api.version=1&domain=example.com&name=mail.example.com&exchange=example.com&preference=10 in WebHost Manager will produce results similar to:

{
   "metadata":{
      "result":1,
      "reason":"Bind reloading on server1 using rndc zone: [example.com]\n",
      "version":1,
      "command":"savemxs"
   }
}

Topic revision: r7 - 23 Aug 2011 - 12:32:04 - MelanieSeibert
AllDocumentation/AutomationIntegration.XmlSaveMxs moved from Sandbox.XmlSaveMxs on 02 Sep 2010 - 19:23 by Main.JustinSchaefer