繁体   English   中英

在 Bluehost CPanel 中使用 PHP 脚本创建电子邮件帐户

[英]Create Email account using PHP script in Bluehost CPanel

我正在尝试在 bluehost 服务器中使用 PHP 脚本创建电子邮件帐户。 我尝试了很多脚本,但它的响应是“拒绝访问”或 file_get_contents( https://...@example.com:2083/frontend/x3/mail/doaddpop.html?email=username@example.com&domain= example.com&password=password&quota=25 ): 无法打开流:HTTP 请求失败! HTTP/1.0 401 拒绝访问。 支持团队表示他们没有任何限制。 我的代码:

脚本 1:

include ("xmlapi.php"); 

$account    = "domain.com"; 
$account_pass   = "domainpass";

$email_user = "username@domain.com";
$email_password = "Mailpassword";
$email_domain   = "domain.com"; 
$email_quota    = '0';

$xmlapi = new xmlapi('xxx.xxx.xxx.xxx'); 
$xmlapi->password_auth($account, $account_pass);
$xmlapi->set_output('xml');

echo $result = $xmlapi->api1_query($account, "Email", "addpop", array($email_user, $email_password, $email_quota, $email_domain) );

脚本2:

 $f = fopen ("https://$cpuser:$cppass@$cpdomain:2082/frontend/$cpskin/mail/doaddpop.html?email=$euser&domain=$edomain&password=$epass&quota=$equota", "r");

 $error = error_get_last();
 echo "HTTP request failed. Error was: " . $error['message'];

 if (!$f) {
 $msg = 'Cannot create email account. Possible reasons: "fopen" function allowed on your server, PHP is running in SAFE mode';
 break;
 }

脚本 3:

$result = $xmlapi->api2_query($cpanel_username, 'Email', 'addpop', $api2args);

脚本 4:

 include ("cpaneluapi.class.php");
 $cpanel = new cpanelAPI(); // Connect to cPanel - only do this once.
 //$cPanel = new cpanelAPI('domain.com', 'Password', 'cpanel.domain.com');

 // Create the user@example.com email address.
 $new_email =  $cpanel->curl_request('https://example.com:2087/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=Email&cpanel_jsonapi_func=addpop&domain="example.com"&email="user"&password="12345luggage"&quota="500"');

 // $new_email = $cpanel->api2(
 //     'Email', 'add_pop',
 //     array(
 //         'email'           => 'user',
 //         'password'        => '12345luggage',
 //         'quota'           => '0',
 //         'domain'          => 'example.com',
 //         'skip_update_db'  => '1',
 //         )
 // );
 echo $new_email;
<?php
include "cpaneluapi.class.php";
$cPanel = new cpanelAPI('username-cpanel', 'password-cpanel', 'hostname-cpanel');
$response = $cPanel->api2->Email->addpop(['email' => 'username-email', 'domain' => 'domain-email', 'quota' => '50', 'password' => 'password-email']);
var_dump($response);
?>

来源: https : //github.com/N1ghteyes/cpanel-UAPI-php-class

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM