< All Topics



Updates the mail exchanger rule to use local or remote server for e-mail sending/receiving.


Additional parameters:

tokenstringYesAuthorizing API token – check API Basics for more information.
accountuserstringYesThe SPanel user account that is being managed or viewed.
actionstringYesThe category and function being executed.
domainstringYesThe domain to apply the new settings.
exchangerstringYes‘localexchanger’ or ‘remoteexchanger’ depending on your preference.
mailserverarrayNoArray of mail servers. Required if ‘exchanger’ set to ‘remoteexchanger’.
priorityarrayNoArray of priorities corresponding to the mail servers. Required if ‘exchanger’ set to ‘remoteexchanger’.


$endpointUrl = '';

$postData = [
  'token' => 'provided_auth_token', // Check API Basics for more information
  'accountuser' => 'spanelio',
  'action' => 'email/setmailroute',
  'domain' => 'spanel.io',
  'exchanger' => 'localexchanger',
//'exchanger' => 'remoteexchanger',
//'mailserver' => ['mail.domain.com', 'mail2.domain.com'],
//'priority' => [0,1]

$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $endpointUrl);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt( $ch, CURLOPT_POST, true);
curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query($postData));
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false);
$jsonOutput = curl_exec( $ch );


    "result": "success",
    "msg": "Your mail exchanger settings for domain spanel.io have been updated"
Previous email/getmailroute
Next email/listemailautoresponders
Table of Contents