Here is a little solution I've managed to come up with for 'creating' new forwarders using the API. It is a pretty simple process. I have tested this for me and it works.
The above code will add a the forwarder beer@yourdomain.com to send all email to /home/username/public_html/parsingScript.php. This works nicely.PHP Code:<?php
// include the class.
include_once "cPanel.php" ;
// set up the vars
$host = 'yourhost.com';
$user = 'username';
$password = 'password';
// create the object
$xmlapi = new xmlapi($host, $user, $password);
// set the port, this is needed as it will default to the whm.
$xmlapi->set_port(2083);
// turn debug mode on.
$xmlapi->set_debug(1);
// set up param array.
$vars['domain'] = 'yourhost.com';
$vars['email'] = 'beer';
$vars['fwdopt'] = 'pipe';
$vars['pipefwd'] = '/home/'.$user.'/public_html/parsingScript.php';
$result = $xmlapi->api2_query($user, 'Email', 'addforward', $vars);
print_r($result);
?>
My problem now begins when I try and delete the forwarder.
Here is my code:
This code sends out the result as:PHP Code:<?php
// include the class.
include_once "cPanel.php" ;
// set up the vars
$host = 'yourhost.com';
$user = 'username';
$password = 'password';
// create the object
$xmlapi = new xmlapi($host, $user, $password);
// set the port, this is needed as it will default to the whm.
$xmlapi->set_port(2083);
// turn debug mode on.
$xmlapi->set_debug(1);
// set up param array.
$vars['forwarder'] = 'beer@yourhost.com=|/home/username/public_html/parsingScript.php';
$result = $xmlapi->api1_query($user, 'Email', 'delforward', $vars);
print_r($result);
?>
SimpleXMLElement Object ( [module] => Email [func] => delforward [type] => event [source] => internal [apiversion] => 1 [data] => SimpleXMLElement Object ( [result] => SimpleXMLElement Object ( ) ) [event] => SimpleXMLElement Object ( [result] => 1 ) [postevent] => SimpleXMLElement Object ( [result] => 1 ) [preevent] => SimpleXMLElement Object ( [result] => 1 ) )
Can anyone make any suggestions to what I might be doing wrong?


LinkBack URL
About LinkBacks
Reply With Quote