Hi guys,
first of all i am new to php, so please bear with me.
I have this requirement wherein i need to automatically create email accounts with my hosting provider through my website's php code.
I have a linux hosting account with cpanel interface (its bluehost.com btw, if that matters).
I came across this cpanel xml api which lets you make api calls to access the function of cpanel through your code. I've donwloaded the api file ('xmlapi.php') and followed the forums and all to write my small php code to call the api to create an email account.
Here's the setup
1) i've uploaded 'xmlapi.php' to root folder of my domains hosting folder
2) i've uploaded another php file 'emailaccount.php' to the root folder
Below is the code inside emailaccount.php
<?php
include_once "xmlapi.php" ;
$ip = "mydomain.com";/*my main domain for the hosting account*/
$domain = "mydomain.com";/*i want to create ckchaudhary@mydomain.com*/
$root_pass = "my_cpanels_password";
$xmlapi = new xmlapi($ip);
$xmlapi->set_auth_type("pass");
$xmlapi->set_output("json");
$xmlapi->password_auth("my_cpanels_login_name",$root_pass);
$xmlapi->set_port(2083);
//$xmlapi->password_auth($domain,$root_pass);
$xmlapi->set_debug(1);
$acct = array( 'username' => "ckchaudhary", 'password' => "Pass1234", 'domain' => $domain);
try{
$response = $xmlapi->createacct($acct);
print_r($response);
echo "<hr/><br/>Email account created successfuly";
}
catch(Exception $e){
echo "<strong>Error : </strong>" . $e->getMessage();
}
?>
The Problem:
$response is always blank. try block is always executed successfuly. But when i login to my cpanel i dont see the new email account listed !
Has anyone worked with cpanel api before? It'd be a great help if someone cud tell me what i need to do