Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

CLI api for adding aliases

Discussion in 'cPanel Developers' started by assid, May 22, 2011.

  1. assid

    assid Registered

    Oct 30, 2006
    Likes Received:
    Trophy Points:

    I am trying to write a script which lets me port from vpopmail to cpanel. However, I am having problems on creating aliases/forwards from cli. I cant seem to find anything in the /scripts directory that would do this.

    Is there a script for this ready? shell/binary which i am not aware off?
  2. cPanelDavidN

    cPanelDavidN Integration Developer

    Dec 17, 2009
    Likes Received:
    Trophy Points:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Hi assid,

    I'm pretty sure that there isn't a script for that. You will need to use the cPanel APIs. There are many threads about using them.

    The APIs are processed either by a cPanel process (spawned by the cpsrvd daemon, like when you log into the cPanel web UI) or via a URL request to the XML/JSON Remote API parser (often referred to as the XML-API).

    For Perl and PHP developers, we have client classes that make this easier ( cPanel::PublicAPI client module for Perl, publicapi-php [beta] client and library for PHP, and XML-API class for PHP ). Each ships with some example code.

    You can always write you own client (or hardcoded calls) based on the documentation here and here. (FYI. once you authenticate in the UI via a browser, you can make these URL queries right in the browser's address bar if you just want to do a quick test without writing code. Just remember to authenticate as the proper user on the proper port...just like your script would).

    The API modules you'll want to look at are probably API2 Email and API1 Email. You should be able to do most everything with the API2 module calls, but there might be something that I'm forgetting. Suffice it to say, any action available in the cPanel UI (like creating a forward) does so using either an API2 or API1 module/function call.

    Best Regards,
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice