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!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to Dynamically generate email forwarders

Discussion in 'cPanel Developers' started by martin MHC, Jan 16, 2018.

  1. martin MHC

    martin MHC Well-Known Member

    Joined:
    Sep 14, 2016
    Messages:
    56
    Likes Received:
    6
    Trophy Points:
    8
    Location:
    UK
    cPanel Access Level:
    Root Administrator
    Hello
    I have a client who would be looking at generating numerous email forwarders on his website account for his staff. As staff come and go forwarders (aka aliases) would need to be added/removed.

    currently I manually change these, but it's monotonous and time consuming for more staff; for me to do grunt work of stating "staff email address <name>@account.com should forward to <staffpersonalemail>@whatever.com".

    I have looked around on XMLAPI php class
    I have also looked at : XML API PHP Class version 1.0
    which looks interesting but:

    1) The code base is ~10 years old.
    2) the code base is no longer maintained.
    3) the code base can no longer be downloaded.
    4) Links such as http://sdk.cpanel.net/lib/xmlapi/php/cp_xmlapi_php_v1.0.7.tar.gz go to a catch page (error 404)

    I do not (think) I want a CPanel plugin . I am working in PHP on the website buildand want to be able to get PHP to instruct the account to set up or delete an email forwarder.

    I don't want a magic bullet answer (uless there is one!) but can a WHM/CPANEL developer give me a sumamry of what sort of processes I need to develop; what sort of interactions I need to code to get something like this to happen?

    I envisage using PHP to update some settings files somewhere in the account homespace, or otherwise to generate a custom API (??) file that PHP can then call and run with variables (email addresses).... but I don't find any valid details on

    1) The Language to work in,
    2) how to set/retrieve this data.

    Any advice on how to judge what I need to do this work would be much appreciated.
     
  2. martin MHC

    martin MHC Well-Known Member

    Joined:
    Sep 14, 2016
    Messages:
    56
    Likes Received:
    6
    Trophy Points:
    8
    Location:
    UK
    cPanel Access Level:
    Root Administrator
    That's exactly what I'm looking for, many thanks William.

    I had searched but hadn't found this.

    A few notes:
    Some Queries:

    • 1) How do I call the LiveAPI from within my PHP script? Should this be only called by a cron job rather than a live script? The LiveAPI loads and then because the __construct is requiring an ENV variable, this will not run as it's not a command line PHP instance.
    • 2) The CPANEL class uses `exec` and other "high risk" functions that are disabled by default in PHP. I can find no way of enabling these functions just for this script/class/instance . Is the CPANEL class subject to these PHP limits and how can they be circumvented? Do these limits also apply to Cron Jobs ( some searching seems to be surprisingly ambiguous on this point)

    • 3) This class overall seems to be geared to being run from the server rather than from any particular hosted account (example: "/home/account/public_html/email_fwder_maker.php")?

      Any clarifications on the above gratefully received. I have looked around the SDK pages but can't see explanations of the above.

      Cheers​
     
    #3 martin MHC, Jan 16, 2018
    Last edited: Jan 16, 2018
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    41,484
    Likes Received:
    1,612
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hi @martin MHC,

    Since this isn't for a cPanel plugin, you should actually avoid using the LiveAPI system. It's intended for use with applications added to the cPanel interface. Instead, you'd want to use a PHP client class like the user-submitted one referenced on the following thread:

    UAPI PHP Class

    Thank you.
     
Loading...

Share This Page