使用xmlapi创建电子邮件帐户时访问被拒绝错误

时间:2016-03-23 05:32:41

标签: php email cpanel-xmlapi

我想使用php创建电子邮件帐户。我为此尝试了xmlapi,但它始终显示访问被拒绝错误。对这个错误有任何想法...... 这是我的代码

    include("xmlapi.php"); 
$ip = "*****"; 
$account = "*****";
$passwd ="*****";
$port =2083;
$email_domain = '*****.com'; 
$email_quota = 50;  

function getVar($name, $def = '') {
  if (isset($_REQUEST[$name]))
    return $_REQUEST[$name];
  else
    return $def;
}
$email_user = getVar('user', '');
$email_pass = getVar('pass', $passwd);
$dest_email = getVar('forward', '');
$msg = '';
$xmlapi = new xmlapi($ip);
$xmlapi->set_port($port);  
$xmlapi->password_auth($account, $passwd); 
$call = array(domain=>$email_domain, email=>$email_user, password=>$email_pass, quota=>$email_quota);
$call_f  = array(domain=>$email_domain, email=>$email_user, fwdopt=>"fwd", fwdemail=>$dest_email);
$xmlapi->set_debug(0);
$result = $xmlapi->api2_query($account, "Email", "addpop", $call ); 
$result_forward = $xmlapi->api2_query($account, "Email", "addforward", $call_f); //create a forward  
if ($result->data->result == 1){
$msg = $email_user.'@'.$email_domain.' account created';
 if ($result_forward->data->result == 1){
     $msg = $email_user.'@'.$email_domain.' forward to '.$dest_email;
     }
} else {
$msg = $result->data->reason;
  break;
}
break;
}
  

提前致谢

0 个答案:

没有答案