How can i create webmail accounts using PHP? I am using cPanel. I tried several scripts开发者_如何学C but none of them seem to work, can someone give me some insight with this?
Thank you very much!!
You need the Cpanel XML API class. Download it here:
http://sdk.cpanel.net/lib/xmlapi/php/cp_xmlapi_php_v1.0.5.tar.gz
It comes with usage examples but this can get you started:
include('xmlapi.php');
$account = "Cogicero";
$account_pass = "password";
$ip = "xxx.xxx.xxx.xxx";
$email_user = "cogicero";
$email_password = "password";
$email_domain = "cogicero.com";
$email_quota = "100";
$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) );
Edit: If you need more information on the API, see this: http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/XmlApi
This example should only modify your access data into a single file config.php and you can create an account easily this way. I hope you find it useful:
include_once '../xmlapi.php';
$xmlapi = new xmlapi(SERVER_IP);
$xmlapi->password_auth(ROOT_USER,ROOT_PASSWORD);
$xmlapi->set_debug(1);
$acct = array( username => "someuser", password => "pass123", domain => "thisdomain.com", plan =>"user_plan_diamond", contactemail=>"user@gmail.com",language=>"es");
print $xmlapi->createacct($acct);
精彩评论