Posssible ways for a PHP script to interact with CPanel email forwarder
On a certain domain there are a bunch of email forwarders such as:
> someone@mydomain.org forwards to someone@gmail.com
This works fine, however, there is a MySQL database and PHP interface the end point client uses, and can set who gets what forwarders.
Each forwarder only goes to one recipient address. Recipient addresses are always off-server.
All email/database/web/files/DNS are on the same server. Nothing is external
Currently:
Upon a change by the client, it sends me an email notification and then I have to manually set up the forwarder using the standard CPanel interface.
Aspiration:
What pointers can be provided as to PHP running a server script (I would write) in either bash/Perl (for example) in order to automate the above change of forwarder address.
For example:
PHP script runs an update to save the new email contact details for a current staff member to the database. Simultaneously the WHM/CPanel/Exim email forwarder is updated from the current text ( someone@mydomain.org forwards to someone@gmail.com ) to the new text ( someone@mydomain.org forwards to someone_new@webmail.com )
QUESTIONS:
1) Can I use bash/Perl to do this? I am more familiar with this language rather than possibly something else.
2) I assume PHP will require some sort of server leve access ( exec(...) / system(...) ) or similar. I keep the server quite tight with disable functions (as these are currently) so curious if there's any workaround options here (probably not)?
3) What location would the raw file be that I would need to open, search and update?
I'm just looking for useful pointers on how to begin achieving the above, thank you.
-
Hey there! The best option is likely the cPanel API to create a forwarder: Guide to the LiveAPI System - PHP Class 0 -
Hey there! The best option is likely the cPanel API to create a forwarder: Guide to the LiveAPI System - PHP Class
Awesome that does actually look exactly like the type of thing I was hoping for. I will explore this and see if I can get it to do as I need. Thanks Rex!0 -
You're welcome! 0
Please sign in to leave a comment.
Comments
3 comments