Child pages
  • cPanel API 2 Functions - Email::delmx

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Description

Excerpt
This function deletes a mail exchanger.

 For more information about mail exchangers, read our Edit MX Entry documentation.

Warning
titleWarning:

We strongly recommend that you use the following UAPI function instead of this function:

  • Email::delete_mx

    Excerpt Include
    DD:UAPI Functions - Email::delete_mxDD:
    UAPI Functions - Email::delete_mx
    nopaneltrue

Multiexcerpt include
SpaceWithExcerptcom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@12665
MultiExcerptNameAPIDisabledDNSRole
PageWithExcerptLIB:_ServerRoleDisabledAPI

Panel
bgColor#F2F2F2
borderStylenone

Examples 


Panel
bgColor#FFFFFF
borderStylenone


Expand
titleWHM API (JSON)


Code Block
languagetext
https://hostname.example.com:2087/cpsess##########/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=Email&cpanel_jsonapi_func=delmx&domain="example.com"&exchange="mail.example.com"&preference="5"

Include Page
LIB:_CallFromWHMAPILink
LIB:_CallFromWHMAPILink


Expand
titleLiveAPI PHP Class


Code Block
languagephp
linenumberstrue
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Delete the mail.example.com mail exchanger.
$delete_mx = $cpanel->api2(
    'Email', 'delmx', 
    array(
        'domain'                => 'example.com', 
        'exchange'              => 'mail.example.com',
        'preference'            => '5',
    ) 
);

Include Page
LIB:_LiveAPIPHPLink
LIB:_LiveAPIPHPLink


Expand
titleLiveAPI Perl Module


Code Block
languageperl
linenumberstrue
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Delete the mail.example.com mail exchanger.
my $delete_mx = $cpliveapi->api2(
    'Email', 'delmx',
    { 
        'domain'                => 'example.com', 
        'exchange'              => 'mail.example.com',
        'preference'            => '5',
    }
);

Include Page
LIB:_LiveAPIPerlLink
LIB:_LiveAPIPerlLink


Expand
titlecPanel Tag System (deprecated)

Include Page
LIB:_cPanelAPI2cPanelTagsWarning
LIB:_cPanelAPI2cPanelTagsWarning


Expand
titleCommand Line


Code Block
languagebash
cpapi2 --user=username Email delmx domain=example.com exchange=mail.example.com preference=5


Note
titleNote:

For more information and additional output options, read our Guide to cPanel API 2 documentation or run the cpapi2 --help command.  



Expand
titleOutput (JSON)


Code Block
languagetext
linenumberstrue
{
  "cpanelresult": {
    "apiversion": 2,
    "func": "delmx",
    "data": [
      {
        "statusmsg": "Removed entry: example.com. 14400\tIN MX 5 mail.example.com\nBind reloading on server1 using rndc zone: [example.com]\n",
        "status": 1,
        "checkmx": {
          "warnings": [
            
          ],
          "issecondary": 0,
          "local": 1,
          "detected": "local",
          "remote": 0,
          "isprimary": 1,
          "changed": 1,
          "secondary": 0,
          "mxcheck": "local"
        },
        "results": "Removed entry: example.com. 14400\tIN MX 5 mail.example.com\nBind reloading on server1 using rndc zone: [example.com]\n"
      }
    ],
    "event": {
      "result": 1
    },
    "module": "Email"
  }
}


Include Page
LIB:_cPanelAPIShellNote
LIB:_cPanelAPIShellNote


Parameters

ParameterTypeDescriptionPossible valuesExample
domainstring

Required

The mail exchanger's domain.

A valid domain on the cPanel account.

example.com
exchangestring

Required

The mail exchanger name.

 

The mail exchanger's name and domain.

mail.example.com
preferenceinteger

Required

The mail exchanger's priority value.

Note
titleNote:

If multiple MX entries match the exchange value, the system uses this parameter to find the correct entry. 


A positive integer.

5

Returns

ReturnTypeDescriptionPossible valuesExample
statusmsgstringA message of success or a reason for failure.
  • A message of success that includes the domain, mail exchange, and server name.
  • A string that describes an error.


Expand
titleClick to view...
Removed entry: example.com. 14400\tIN MX 5 mail.example.com\nBind reloading on server1 using rndc zone: [example.com]\n


statusBooleanWhether the function succeeded.
  • 1 — The function succeeded.
  • 0 — The function failed.
1
checkmxhashA hash of the mail exchanger's data.This hash includes the warnings, issecondary, local, detected, remote, isprimary, changed, secondary, and mxcheck returns. 

warnings

string

Warning messages, if any exist.

The function returns this value in the checkmx hash.

One or more warning messages.


Expand
titleClick to view...
Auto Detect of MX configuration not possible due to non-resolving MX entries.  Defaulting to last known setting: local.


issecondary

Boolean

Whether the mail exchanger is a secondary exchanger.

The function returns this value in the checkmx hash.

  • 1 — Secondary.
  • 0 — Not secondary.

0

local

Boolean

Whether the mail exchanger is a local exchanger.

The function returns this value in the checkmx hash.

  • 1 — Local.
  • 0 — Not local.
0

detected

string

The mail exchanger type.

The function returns this value in the checkmx hash.

  • auto
  • local
  • secondary
  • remote
auto

remote

Boolean

Whether the mail exchanger is a remote exchanger.

The function returns this value in the checkmx hash.

  • 1 — Remote.
  • 0 — Not remote.
0

isprimary

Boolean

Whether the mail exchanger is the primary mail exchanger.

The function returns this value in the checkmx hash.

  • 1 — Primary.
  • 0 — Not primary.
0

changed

Boolean

Whether a change occurred during the function.

The function returns this value in the checkmx hash.

  • 1 — Change occurred.
  • 0 — No change.
1

secondary

Boolean

Whether the mail exchanger is a secondary exchanger.

The function returns this value in the checkmx hash.

  • 1 — Secondary.
  • 0 — Not secondary.

0

mxcheck

string

The mail exchanger type.

The function returns this value in the checkmx hash.

  • auto
  • local
  • secondary
  • remote
auto
resultsstringA message of success or a reason for failure.
  • A message of success that includes the domain, mail exchange, and server name.
  • A string that describes an error.


Expand
titleClick to view...
Removed entry: example.com. 14400\tIN MX 5 mail.example.com\nBind reloading on server1 using rndc zone: [example.com]\n


reasonstring

A reason for failure.

Note
titleNote:

This function only returns a reason value if it failed. 


A string that describes the error.

This is an error message.
resultBoolean

Whether the function succeeded.

  • 1 — The function succeeded.
  • 0 — The function failed.
1