cPanel API 2 Functions - Email::setalwaysaccept

Description

This function modifies a mail exchanger's type. 

Warning:

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

  • Email::set_always_accept — This function sets the Mail Exchanger (MX) type.

Notes:

  • This function only affects the cPanel configuration. You must configure the mail exchanger's DNS entry separately.
  • This function is similar to the Email::setmxcheck function, but hooks and custom event handlers parse them as unique calls. 

 

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=setalwaysaccept&domain=

 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''setalwaysaccept'
    array(
        'domain'                => 'example.com'
        'mxcheck'               => 'local',
        'user'                  => 'cpaneluser',
    
);

 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''setalwaysaccept',
    {
        'domain'                => 'example.com',
        'mxcheck'               => 'local',
        'user'                  => 'cpaneluser',
    }
);

 cPanel Tag System (deprecated)

Warning:

In cPanel & WHM version 11.30 and later, cPanel tags are deprecated. We strongly recommend that you only use the LiveAPI system to call the cPanel APIs.

cPanel API 2 calls that use cPanel tags vary widely in code syntax and in their output. For more information, read our Deprecated cPanel Tag Usage documentation. Examples are only present in order to help developers move from the old cPanel tag system to our LiveAPI.


 Output (JSON)

{
  "cpanelresult": {
    "apiversion": 2,
    "func": "setalwaysaccept",
    "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"
  }
}

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 

 Required

 The mail exchanger's domain.

 A valid domain on the cPanel account.

 example.com 

 mxcheck

 string

 Required

 The mail exchanger type.

  

  • auto — Allow cPanel to determine the appropriate role.
  • local — Always accept the domain's mail.
  • secondary — Accept mail until a higher priority mail server is available. 
  • remote — Do not accept mail.

 auto

 user

 string

 Required

 The cPanel account username. 

 The cPanel account's username.

 cpaneluser

 

Returns

Return

Type

Description

Possible values

Example

 statusmsg

 string

 A message of success or a reason for failure.

  • A message of success that includes the new type.
  • A string that describes an error.

 Set Always Accept Status to: local

 status

 boolean

 Whether the function succeeded.

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

 1

 checkmx

 hash

 A hash of the mail exchanger's data.

 This hash contains thewarnings, issecondary,local, detected,remote, isprimary,changed, secondary, andmxcheck parameters.

  

 warnings

 string

 Warning messages, if any exist.

 The function returns this parameter in thecheckmx hash.

 One or more warning messages.

  

 issecondary

 boolean

 Whether the mail exchanger is a secondary exchanger.

 The function returns this parameter in thecheckmx hash.

  • 1 — Secondary.
  • 0 — Not secondary.

 0

 local

 boolean

 Whether the mail exchanger is a local exchanger.

 The function returns this parameter in thecheckmx hash.

  • 1 — Local.
  • 0 — Not local.

 0

 detected

 string

 The mail exchanger type.

 The function returns this parameter in thecheckmx hash.

  • auto
  • local
  • secondary
  • remote

 auto

 remote

 boolean

 Whether the mail exchanger is a remote exchanger.

 The function returns this parameter in thecheckmx hash.

  • 1 — Remote.
  • 0 — Not remote.

 0

 isprimary

 boolean

 Whether the mail exchanger is the primary mail exchanger. 

 The function returns this parameter in thecheckmx hash.

  • 1 — Primary.
  • 0 — Not primary.

 0

 changed

 boolean

 Whether a change occurred during the function.

 The function returns this parameter in thecheckmx hash.

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

 1

 secondary

 boolean

 Whether the mail exchanger is a secondary exchanger.

 The function returns this parameter in thecheckmx hash.

  • 1 — Secondary.
  • 0 — Not secondary.

 0

 mxcheck

 string

 The mail exchanger type.

 The function returns this parameter in thecheckmx hash.

  • auto
  • local
  • secondary
  • remote

 auto

 local

 boolean

 Whether the mail exchanger is a local exchanger.

  • 1 — Local.
  • 0 — Not local.

 0

 remote

 boolean

 Whether the mail exchanger is a remote exchanger.

  • 1 — Remote.
  • 0 — Not remote.

 0

 detected

 string

 The mail exchanger type.

  • auto
  • local
  • secondary
  • remote

 auto

 mxcheck

 string

 The mail exchanger type.

  • auto
  • local
  • secondary
  • remote

 auto

 secondary

 boolean

 Whether the mail exchanger is a secondary exchanger.

  • 1 — Secondary.
  • 0 — Not secondary.

 0

 results

 string

 A message of success or a reason for failure.

  • A message of success that includes the new type.
  • A string that describes an error.

 Set Always Accept Status to: local 

 reason

 string

 A reason for failure.

 Note:

 This function only returns areasonvalue if it failed. 

 A string that describes the error.

 This is an error message.

 result

 boolean 

 Whether the function succeeded.

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

 1

  

 
  • 8 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....