WHMAPI1 modifyacct MXCHECK not saved

HaydenKatz

Registered
Sep 11, 2018
3
0
1
Australia
cPanel Access Level
Root Administrator
Hi All,

I am trying to change a user's MX routing options via API with the "MX Entry" feature disabled for the user.
After a long search, it appears that this should be done via the WHMAPI1 command 'modifyacct', specifying the MXCHECK-<domain>=string option.
In testing via the command line however, this does not appear to be the case.

I have a test account 'example.com' for user mrzt63d9 on the server. I have made the following attempts, however it always returns MXCHECK-example.com=remote

  • whmapi1 modifyacct user=mrzt63d9 MXCHECK-example.com=local
  • whmapi1 modifyacct user=mrzt63d9 MXCHECK-example%2Ecom=local
  • whmapi1 modifyacct user=mrzt63d9 MXCHECK%2Dexample%2Ecom=local
  • whmapi1 modifyacct user=mrzt63d9 MXCHECK-example.COM=local
  • whmapi1 modifyacct user=mrzt63d9 MXCHECK-example%2ECOM=local
  • whmapi1 modifyacct user=mrzt63d9 MXCHECK%2Dexample%2ECOM=local
  • whmapi1 modifyacct user=mrzt63d9 MXCHECK=local

I've also attempted with integer values (0, 1, 2) with the same result.

How can I alter this option via API without enabling "MX Entry" in the user's feature list and backdooring UAPI/API2?
 
Last edited by a moderator:

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,272
313
Houston
Hi @HaydenKatz


The UAPI function here should do this for you:

UAPI Functions - Email::change_mx - Developer Documentation - cPanel Documentation

I tested it just to make sure:

Code:
uapi --user=myuser Email change_mx domain=mydomain.tech exchanger=mail.mydomain.tech oldexchanger=mail.mydomain.tech priority=10 alwaysaccept=remote

---
apiversion: 3
func: change_mx
module: Email
result:
  data:
    checkmx:
      changed: 1
      detected: remote
      isprimary: 0
      issecondary: 0
      local: 0
      mxcheck: remote
      remote: 1
      secondary: 0
      warnings: []

    results: "Added entry: mydomain.tech.    IN    MX    10    mail.mydomain.tech.\n\nBind reloading on server using rndc zone: [mydomain.tech]\n"
    status: 1
    statusmsg: "Added entry: mydomain.tech.    IN    MX    10    mail.mydomain.tech.\n\nBind reloading on server using rndc zone: [mydomain.tech]\n"
  errors: ~
  messages: ~
  metadata: {}

  status: 1
  warnings: ~
Then switched it back to make sure it was reflected properly:

Code:
uapi --user=myuser Email change_mx domain=mydomain.tech exchanger=mail.mydomain.tech oldexchanger=mail.mydomain.tech priority=10 alwaysaccept=local
---
apiversion: 3
func: change_mx
module: Email
result:
  data:
    checkmx:
      changed: 1
      detected: local
      isprimary: 1
      issecondary: 0
      local: 1
      mxcheck: local
      remote: 0
      secondary: 0
      warnings: []

    results: "Reusing existing entry on line matched new entry and new priority: 48:\nNo dns changes are required"
    status: 1
    statusmsg: "Reusing existing entry on line matched new entry and new priority: 48:\nNo dns changes are required"
  errors: ~
  messages: ~
  metadata: {}

  status: 1
  warnings: ~

To further confirm it stayed:

Code:
uapi --user=myuser Email list_mxs domain=mydomain.tech |egrep 'remote|local'

      detected: local
      local: 1
      mxcheck: local
      remote: 0
Thanks!
 

HaydenKatz

Registered
Sep 11, 2018
3
0
1
Australia
cPanel Access Level
Root Administrator
Hi @cPanelLauren,

I'm afraid this won't help.
As noted in the original topic, we are disabling the changemx feature feature (IE: MX Entry) for our users.
When attempting to perform this on a user without "MX Entry" enabled in features, we receive: "This feature requires the “changemx” option and is not enabled on your account."

This is why I was attempting to do so with WHMAPI1 - which is stated in the documentation to have this ability, but near as I can tell it does not work.

WHM can do it (Available in "Edit MX Entry"), so I was hoping there was a way I could manage this remotely, without needing to enable the feature for the user.

The reason for this is that we use 3rd party DNS - which the cPanel server is not bound to, and the "MX Entry" option allows customers to update the actual record as well (On the server's local DNS, which is meaningless to the customer), not just the routing options.
This causes confusion for the customer, and an increased number of support tickets.

Kind Regards,

Hayden Katz.