【问题标题】:cpanel email account creation issuecpanel电子邮件帐户创建问题
【发布时间】:2016-05-06 15:19:11
【问题描述】:

我正在尝试通过脚本创建一个电子邮件帐户,而无需登录 cpanel。 这是我正在使用的脚本

http://www.zubrag.com/scripts/cpanel-create-email-account.php

主机提供商是 bluehost

我收到了这个错误

Cannot create email account. Possible reasons: "fopen" function allowed on your server, PHP is running in SAFE mode

我的 ini 文件中的安全模式已关闭。

这是脚本正在使用的凭据区域

// cPanel info
$cpuser = 'example.com'; // cPanel username
$cppass = 'my_cpanel_pass'; // cPanel password
$cpdomain = 'example.com'; // cPanel domain or IP
$cpskin = 'x';  // I have tried x and also bluehost here

// Default email info for new email accounts
// These will only be used if not passed via URL
$epass = 'my_cpanel_pass'; // email password
$edomain = 'example.com'; // email domain (usually same as cPanel domain above)
$equota = 20; // amount of space in megabytes

以下代码向我发送错误/警告

$f = fopen ("http://$cpuser:$cppass@$cpdomain:2082/frontend/$cpskin/mail/doaddpop.html?email=$euser&domain=$edomain&password=$epass&quota=$equota", "r");
  if (!$f) {
    $msg = 'Cannot create email account. Possible reasons: "fopen" function allowed on your server, PHP is running in SAFE mode';
    break;
  }

我得到的警告是

Warning: fopen(http://...@example.com:2082/frontend/x/mail/doaddpop.html?email=asif.k&domain=example.com&password=SmallAn123!&quota=20): failed to open stream: HTTP request failed! HTTP/1.1 401 Access Denied in E:\Web Softs\wamp\www\clnt5\cpemail.php on line 81

如果我打印 fopen() 之间的所有内容,我会得到这个

http://cpanel_user_name:my_cpanel_pass@example.com:2082/frontend/x/mail/doaddpop.html?email=asif.k&domain=mydomain.com&password=SmallAn123!&quota=20

我已经用谷歌搜索了很多来解决这个问题。任何可以帮助我实现这一目标的帮助或替代脚本将不胜感激。

【问题讨论】:

  • 网址不应该是http://cpanel_user_name:cpanel_password@example.com:2082/...
  • 对不起我的错误。 URL 与您指定的方式相同。但是这个脚本真的让我很生气
  • 我认为 cPanel 不能让您自动添加邮件帐户,我认为您需要为此使用 WHM。
  • @Jamesking56 你的意思是这个任务的死胡同?难道不能通过像这样的脚本来实现codecanyon.net/item/cpanel-email-creator/168805

标签: php function web cpanel cpanel-xmlapi


【解决方案1】:

如果您有 cpanel 用户名和密码,那么您应该使用 cpanel API 来创建电子邮件帐户和更多功能,而不是这些获取请求。

        require_once 'xmlapi.php';
        $xmlapi = new \xmlapi($cpanel_domain);

        $xmlapi->password_auth($cpanel_username,$cpanel_password);

        $xmlapi->set_port('your domain port will be here');

        $api2args = array();                            
        $result = $xmlapi->api1_query($cpanel_password, 'CustInfo', 'getemail', $api2args);
         // until here you will get confirmation of your connected cpanel with cpanel api
         // then create cpanel as below
          $api2args = array(
            'domain'          => $domain, 
            'email'           => $email_address_to_create, 
            'password'        => $email_password,
            'quota'           => '2048',    // quota for email you want to set                          
            );
            $result = $xmlapi->api2_query($cpanel_username, 'Email', 'addpop', $api2args);

        if(isset($result->error) && $result->error!=""){                
            // error can be recorded here
        }
        else{
           // email account get created
        }

【讨论】:

    猜你喜欢
    • 2013-06-10
    • 1970-01-01
    • 1970-01-01
    • 2016-05-14
    • 2016-08-27
    • 2013-01-27
    • 2019-10-16
    • 2011-09-19
    • 2017-02-13
    相关资源
    最近更新 更多