Skip to main content

cPanel uapi API to change mail exchanger via command line

Comments

8 comments

  • JAB Creations

    Finn, thanks though that page is incomplete. Yes, it's possible to derive the values for the CLI mxcheck parameter from cPanel itself though that isn't documented here on cPanel's actual website!

    This website has that clarified (though the # is broken so scroll to the parameters header):

    https://portal.thelinuxfix.com/index.php?rp=/knowledgebase/833/UAPI-Functions---Emailset_always_accept.html

    I'll actually have to try it out a little later on to confirm the parameters listed on that third party website work though I feel confident that they will.

    So the documentation needs to be updated for cPanel. It's the weekend of course, hopefully a cPanel employee will see this.

    0
  • JAB Creations

    So here is the proper syntax for anyone else having to decipher the ...messy documentation:

    uapi Email set_always_accept domain='example.com' mxcheck='local'
    uapi Email set_always_accept domain='example.com' mxcheck='auto'
    uapi Email set_always_accept domain='example.com' mxcheck='backup'
    uapi Email set_always_accept domain='example.com' mxcheck='remote'

    So the documentation page is https://api.docs.cpanel.net/openapi/cpanel/operation/set_always_accept/

    The alwaysaccept parameter is the subparameter of the Email parameter, the documentation implies that it could be the key with one of the enumerated values however that is incorrect, at least in regards to using uapi. So that is why I posted the static examples of the commands above.

    Note for anyone lost when executing the commands in the Linux terminal the --user= parameter must be defined though not when called via PHP. PHP can call the terminal using the whoami to get the Linux user that PHP runs under.

    So it would be nice if someone from the cPanel team could take a few minutes to clean up that documentation page to spare others from the confusion.

    0
  • cPRex Jurassic Moderator

    JAB Creations - what updates would you like to see on that page, specifically?

    1
  • JAB Creations

    Rex, I hope you're doing well! To start, an anatomy break down of a cPanel UAPI CLI call:

    uapi Email set_always_accept domain='example.com' mxcheck='local'

    1. uapi - The API.
    2. Email - The command group.
    3. set_always_accept - The specific command.
    4. domain='example.com' - The domain parameter.
    5. mxcheck='local' - The command setting.

    So the most important thing in documentation is to not only have a working example though one that most people can relate with. That documentation page mixes up the set_always_accept and mxcheck parts. Thankfully after creating my verification script to ensure all cPanel API calls still work when testing server calls I've got a pretty good idea of how the structure works and dicphered it. Now that I'm used to cPanel commands I think this particular documentation page is over-clarifying, like whoever did that was trying to clarify to someone who had a specific problem with this command. But instead of providing a clean example they went 1990s math book and went overkill without a working example.

    On the right side under "Request samples" with the CLI visible by default there is no mxcheck parameter. That was probably what started throwing me off and then the oddities about not using set_always_accept in place of mxcheck. The minor omission completely threw me off to start though third party documentation led me to reevaluate the page since the accepted mxcheck values line up with what I had seen in cPanel directly.

    0
  • cPRex Jurassic Moderator

    Thanks for the great reply - I've submitted case DOCS-376 to get that API doc updated so it's more clear in the future!

    1
  • JAB Creations

    Rex, you're results driven and I appreciate that, thanks!

    0
  • cPRex Jurassic Moderator

    I do try!

    1

Please sign in to leave a comment.