I have a two tiered question:
First, I have a VPS on which I am expecting to sell hosting accounts. I don't really want users having access to cPanel, yet I want to enable them to create email accounts through an application I will build.
I found your script as represented below and it seemed like the perfect solution for me.
PHP Code:
$account = "dave";
$account_pass = "d4v3sSecret!";
$email_user = "mr_dave";
$email_password = "my_s3cr3t_pop!passwd";
$email_domain = "dave.com";
$email_quota = '0';
$xmlapi = new xmlapi($ip);
$xmlapi->password_auth($account, $account_pass); <-- USE USER ACCOUNT AUTH
$xmlapi->set_output('xml');
$result = $xmlapi->api1_query($account, "Email", "addpop", array($email_user, $email_password, $email_quota, $email_domain) );
My problem is that although I can get the account name by exploding getenv("DOCUMENT_ROOT"), I have no way of getting their password information, and so I can't authenticate the request dynamically as I need to.
I need to find a way to extract their password and assign it to a variable to be used in authentication.
Part two of my problem is that I've tried doing it with static values:
PHP Code:
include("xmlapi.php");
$account_pass = "xxxx";
$ip = getenv('REMOTE_HOST');
$account = "xxxx";
$email_user = "xxxx";
$email_password = "xxxx";
$email_domain = "xxxx";
$email_quota = '0';
//
$xmlapi = new xmlapi($ip);
$xmlapi->password_auth($account, $account_pass);
$xmlapi->set_output('xml');
//
$result = $xmlapi->api1_query($account, "Email", "addpop", array($email_user, $email_password, $email_quota, $email_domain) );
And I'm still getting an error message:
Fatal error: Uncaught exception 'Exception' with message 'No host defined' in /home/xxxx/public_html/xmlapi.php:218 Stack trace: #0 /home/xxxx/public_html/api1_example.php(36): xmlapi->__construct(false) #1 {main} thrown in /home/xxxx/public_html/xmlapi.php on line 218
I'm pretty new to using this API, but I thought I followed the example explicitly. Is there anything wrong with my logic? Is there something else I need to try?
My cPanel version is 11.28.87
Thanks in Advance,
Aaron -