How to Dynamically generate email forwarders
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 @account.com should forward to @whatever.com".
I have looked around on
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
-
Hi @martin MHC, Please check the following documentation: UAPI Functions - Email::add_forwarder - Software Development Kit - cPanel Documentation UAPI Functions - Email::delete_forwarder - Software Development Kit - cPanel Documentation Guide to the LiveAPI System - PHP Class - Software Development Kit - cPanel Documentation I believe using the UAPI with the LiveAPI PHP class will work nicely here. Thanks, 0 -
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
0 -
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.
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: Thank you.0
Please sign in to leave a comment.
Comments
3 comments