UAPI Functions - Email::list_mxs

Description

This function lists Mail Exchanger (MX) records.

Examples 


 cPanel or Webmail Session URL

https://hostname.example.com:2083/cpsess##########/execute/Email/list_mxs?domain=example.com

 LiveAPI PHP Class

$cpanel new CPANEL(); // Connect to cPanel - only do this once.
  
// List example.com's MX record.
$get_mx_list $cpanel->uapi(
    'Email''list_mxs',
    array(
        'domain'        => 'example.com',
         )
);

 LiveAPI Perl Module

my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
  
# List example.com's MX record.
my $get_mx_list $cpliveapi->uapi(
    'Email''list_mxs',
    {
        'domain'        => 'example.com',
    }
);

 cPanel Template Toolkit

<!-- Get a list of example.com's mail exchangers, then display the mx values. -->
[% data = execute( 'Email', 'list_mxs', { 'domain' => 'example.com' } ); %]
[% FOREACH q = data.entries.mx %]
     <p>
         [% q %]
     </p>
[% END %]
   
<!-- Get only the mx values. -->
[% execute('Email', 'list_mxs', { 'domain' => 'example.com' } ).data.entries.mx %]

 Command Line

uapi --user=username Email list_mxs domain=example.com

 

Notes:

  • You must URI-encode values.
  • username represents your account-level username.

 Output (JSON)

   "messages":null,
   "errors":null,
   "status":1,
   "metadata":{ 
      "transformed":1
   },
   "data":[ 
      
         "statusmsg":"Fetched MX List",
         "entries":[ 
            
               "mx":"newmx.example.com",
               "priority":"0",
               "domain":"example.com",
               "entrycount":1,
               "row":"odd"
            },
            
               "mx":"mail.example.com",
               "priority":"5",
               "domain":"example.com",
               "entrycount":2,
               "row":"even"
            },
            
               "mx":"mx.example.com",
               "priority":"10",
               "domain":"example.com",
               "entrycount":3,
               "row":"odd"
            },
            
               "mx":"mail4.example.com",
               "priority":"15",
               "domain":"example.com",
               "entrycount":4,
               "row":"even"
            }
         ],
         "status":1,
         "local":0,
         "detected":"local",
         "remote":0,
         "mx":"newmx.example.com",
         "domain":"example.com",
         "secondary":0,
         "mxcheck":"local",
         "alwaysaccept":1
      }
   ]
}

Note:

Use cPanel's API Shell interface (Home >> Advanced >> API Shell) to directly test cPanel API calls.

 

Parameters

 Parameter 

 Type 

Description

Possible values

Example

domain

 string 

The domain to query.

 If you do not use this parameter, the function returns MX records for all of the cPanel account's domains. 

 A valid domain on the account. 

 example.com 

 

Returns

Return

Type

Description

Possible values

Example

statusmsg

string

A message of success, or an error message.

  • A message of success that begins withAdded entry:
  • An error message.

Fetched MX List

entries

 array of hashes 

An array of hashes of mail exchangers.

Each hash includes the mx, priority,domain, entrycount, and row returns.

 

mx

string

The mail exchanger's name.

The function returns this value in the entries hash.

A valid mail exchanger name.

newmx.example.com

priority

integer

The mail exchanger's priority value.

The function returns this value in the entries hash.

An integer.

5

domain

string

The mail exchanger's domain.

The function returns this value in the entries hash.

A valid domain name on the cPanel account.

example.com

entrycount

integer

The mail exchanger's order in the list of priorities.

The function returns this value in the entries hash.

A positive integer.

 For example, the mail exchanger with the highest priority returns 1, and the next highest priority returns 2. 

1

row

string

Whether the mail exchanger is an odd or an even entry.

The function returns this value in the entries hash.

  • even
  • odd

odd

status

Boolean

Whether the function succeeded.

  • 1 — Success.
  • 0 — Failure.

1

local

Boolean

 Whether the domain's highest priority mail exchanger is a local mail exchanger. 

  • 1 — Local.
  • 0 — Not local.

1

detected

string

The domain's highest-priority mail exchanger's type.

  • auto
  • local
  • remote
  • secondary

local

remote

Boolean

Whether the domain's highest-priority mail exchanger is remote.

  • 1 — Remote.
  • 0 — Not remote.

0

mx

string

The domain's highest-priority mail exchanger's name.

A valid mail exchanger on the domain or cPanel account.

 newmx.example.com 

domain

string

The domain.

A valid domain on the cPanel account.

example.com

secondary

Boolean

Whether the domain's highest-priority mail exchanger is secondary.

  • 1 — Secondary.
  • 0 — Not secondary.

0

mxcheck

string

The domain's highest-priority mail exchanger's type.

  • auto
  • local
  • remote
  • secondary

auto

 alwaysaccept 

Boolean

Whether the domain's highest-priority mail exchanger accepts local mail.

  • 1 — Accept local mail.
  • 0 — Does not accept local mail.

1

 

 

  • 3 Users Found This Useful
Was this answer helpful?

Related Articles

The cPanel Interface

For  cPanel  &  WHM  version  58 Overview The cPanel interface is...

User Preferences

For cPanel & WHM version 58 Overview This document outlines how to access your cPanel...

Manage External Authentications

For cPanel & WHM version 58 Overview Manage credentials Additional documentation...

What is cPanelID?

In This Article:  Overview ServicesHow to get a cPanelID cPanelID External...

Guide to cPanel Interface Customization - cPanel Style Development

Introduction You can develop custom styles that modify the appearance of the cPanel interface....