PDA

View Full Version : Creating email forwarders outside of CPanel


warm
12-09-2007, 10:34 PM
Hello,

I'm making a web application for someone, and they want to be able to create email forwarders through the application instead of through CPanel (making it a feature of the application). They'd be doing this as memberships change, and they are very non-technical and don't even want to touch CPanel.

Is this possible? If so, how can it be done? I'm using PHP and CPanel is written in PHP, so I'm hoping there might be a way to access those functions from the outside, but I'm not sure if it's possible.

Thanks in advance for any help!

warm
12-10-2007, 06:06 PM
OK, I've got a workaround that involves having PHP create a socket and provide the basic authentication required to successfully add (by POSTing data) and retrieve existing email forwarders, but I'd like to do it the "clean" way, if at all possible...

Cirtex Andrew
12-13-2007, 09:21 PM
You can create the mail forwarders in CPanel by either using curl or the file_get_contents command in PHP and opening the CPanel URL to create the forwarder. I do not know the exact arguments to use but you can find that out fairly easily by doing a search or by playing around in CPanel.

ex: file_get_contents('http://cpaneluser:cpanelpass@yourdomain.com:2082/frontend/x3/mail/addfwd.html?email=email1@yourdomain.com&forwardto=email1@anotherdomain.com');

warm
12-13-2007, 09:58 PM
That looks pretty good - I'll give it a shot.

Thank you!