cPanel API 2 Functions - Email::setmxcheck
The cPanel API 2 system is deprecated. We strongly recommend that you use UAPI instead of cPanel API 2.
Description
This function modifies a mail exchanger's type. For more information about MX record settings, read our Email Routing Configuration documentation.
- This function only affects the cPanel configuration. You must configure the mail exchanger's DNS entry separately.
-
This function is similar to the cPanel API 2
Email::setalwaysaccept
function, but hooks and custom event handlers parse them as unique calls.
We strongly recommend that you use UAPI instead of cPanel API 2. However, no equivalent UAPI function exists.
When you disable the Receive Mail role, the system disables this function.
Examples
WHM API (JSON)
https://hostname.example.com:2087/cpsess##########/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=Email&cpanel_jsonapi_func=setmxcheck&domain="example.com"&mxcheck="auto"
For more information, read our Calls from the WHM API documentation.
LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
// Change example.com's mx type to local.
$set_mx_type = $cpanel->api2(
'Email', 'setmxcheck',
array(
'domain' => 'example.com',
'mxcheck' => 'local',
)
);
For more information, read our Guide to the LiveAPI System.
LiveAPI Perl Module
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
# Change example.com's mx type to local.
my $set_mx_type = $cpliveapi->api2(
'Email', 'setmxcheck',
{
'domain' => 'example.com',
'mxcheck' => 'local',
}
);
For more information, read our Guide to the LiveAPI System.
cPanel Tag System (deprecated)
- cPanel tags are deprecated . We strongly recommend that you only use the LiveAPI system to call the cPanel APIs. Examples are only present in order to help developers move from the old cPanel tag system to our LiveAPI .
- cPanel API 2 calls that use cPanel tags vary in code syntax and in their output.
- For more information, read our Deprecated cPanel Tag Usage documentation.
Command Line
cpapi2 --user=username Email setmxcheck domain=example.com mxcheck=local
- You must URI-encode values.
-
username
represents your account-level username. -
You
must
run the
--user=username
command. -
For more information and additional output options, read our
Guide to cPanel API 2
documentation or run the
cpapi2 --help
command. -
If you run CloudLinux™, you
must
use the full path of the
cpapi2
command:/usr/local/cpanel/bin/cpapi2
Output (JSON)
{
"cpanelresult": {
"apiversion": 2,
"func": "setmxcheck",
"data": [
{
"statusmsg": "Set Always Accept Status to: local",
"status": 1,
"checkmx": {
"warnings": [
],
"issecondary": 0,
"local": 1,
"detected": "local",
"remote": 0,
"isprimary": 1,
"changed": 1,
"secondary": 0,
"mxcheck": "local"
},
"local": 1,
"remote": 0,
"detected": "local",
"mxcheck": "local",
"secondary": 0,
"results": "Set Always Accept Status to: local"
}
],
"event": {
"result": 1
},
"module": "Email"
}
}
Use cPanel's API Shell interface (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.
Parameters
Parameter | Type | Description | Possible values | Example |
---|---|---|---|---|
domain |
string | Required The mail exchanger's domain. |
A valid domain on the cPanel account. |
example.com |
mxcheck |
string | Required The mail exchanger type.
|
|
auto |
Returns
Return | Type | Description | Possible values | Example |
---|---|---|---|---|
statusmsg |
string | A message of success or a reason for failure. |
|
Set Always Accept Status to: local |
status |
Boolean | Whether the function succeeded. |
|
1 |
checkmx |
hash | A hash of the mail exchanger's data. | This hash contains the warnings array and the issecondary , local , detected , remote , isprimary , changed , secondary , and mxcheck returns. |
|
|
array | An array of warning messages, if any exist. The function returns this array in the |
One or more warning messages. | Auto Detect of MX configuration not possible due to non-resolving MX entries. Defaulting to last known setting: local.
|
|
Boolean |
Whether the mail exchanger is a secondary exchanger. The function returns this value in the |
|
|
|
Boolean | Whether the mail exchanger is a local exchanger. The function returns this value in the |
|
0 |
|
string | The mail exchanger type. The function returns this value in the |
|
auto |
|
Boolean | Whether the mail exchanger is a remote exchanger. The function returns this value in the |
|
0 |
|
Boolean | Whether the mail exchanger is the primary mail exchanger. The function returns this value in the |
|
0 |
|
Boolean | Whether a change occurred during the function. The function returns this value in the |
|
1 |
|
Boolean | Whether the mail exchanger is a secondary exchanger. The function returns this value in the |
|
|
|
string | The mail exchanger type. The function returns this value in the |
|
auto |
local |
Boolean | Whether the mail exchanger is a local exchanger. |
|
0 |
remote |
Boolean | Whether the mail exchanger is a remote exchanger. |
|
0 |
detected |
string | The mail exchanger type. |
|
auto |
mxcheck |
string | The mail exchanger type. |
|
auto |
secondary |
Boolean | Whether the mail exchanger is a secondary exchanger. |
|
|
results |
string | A message of success or a reason for failure. |
|
Set Always Accept Status to: local |
reason |
string | A reason for failure. Note:
This function only returns a |
A string that describes the error. |
This is an error message. |
result |
Boolean | Whether the function succeeded. |
|
1 |