使用PHP创建Webmail帐户

时间:2011-04-01 15:58:25

标签: php cpanel webmail

如何使用PHP创建网络邮件帐户?我正在使用cPanel。我尝试了几个脚本但是它们似乎都没有用,有人可以给我一些见解吗?

非常感谢!!

2 个答案:

答案 0 :(得分: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

答案 1 :(得分: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=>"user@gmail.com",language=>"es");
print $xmlapi->createacct($acct);