0

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

2
Contributors
2
Replies
6
Views
5 Years
Discussion Span
Last Post by ckchaudhary
0

Doesn't your webhost provide any documentation for this? Have you contacted them to ask whether or not it is supported at all?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.