2011-04-01 71 views
0

如何使用PHP創建webmail帳戶?我正在使用cPanel。我嘗試了幾個腳本,但他們都沒有工作,有人能給我一些見解嗎?使用PHP創建webmail帳戶

非常感謝!

回答

2

您需要Cpanel XML API類。在這裏下載:

http://sdk.cpanel.net/lib/xmlapi/php/cp_xmlapi_php_v1.0.5.tar.gz

它配備了使用的例子,但是這可以讓你開始:

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)); 

編輯:如果您需要在API的更多信息,請參閱本:http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/XmlApi

+0

謝謝!似乎是我所需要的,但是當我嘗試使用我的信息的例子時,我得到500內部服務器錯誤,關於什麼可能是什麼想法?謝謝! – luqita 2011-04-01 21:17:53

+0

得到它的工作:)謝謝! – luqita 2011-04-02 01:33:13

+0

現在就來得到這個。不客氣,luqita :) – Cogicero 2011-04-03 09:57:53

0

This example應該只將您的訪問數據修改爲單個文件config.php,您可以通過這種方式輕鬆創建帳戶。 我希望你覺得它有用:

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=>"[email protected]",language=>"es"); 
print $xmlapi->createacct($acct);