cPanel是我們在服務器上安裝的Web服務器管理應用程序。它有一個XML/JSON的基於,我們要使用它來訪問數據,如所有電子郵件帳戶的列表。這個系統是huge,我無法在任何地方找到答案。有誰知道如何使用cPanel API列出電子郵件帳戶?如何使用cPanel API訪問電子郵件帳戶列表?
編輯:我需要的是listpopswithdisk
(docs here)的功能,列出一個給定域下的電子郵件帳戶,但不知道如何調用該函數。
cPanel是我們在服務器上安裝的Web服務器管理應用程序。它有一個XML/JSON的基於,我們要使用它來訪問數據,如所有電子郵件帳戶的列表。這個系統是huge,我無法在任何地方找到答案。有誰知道如何使用cPanel API列出電子郵件帳戶?如何使用cPanel API訪問電子郵件帳戶列表?
編輯:我需要的是listpopswithdisk
(docs here)的功能,列出一個給定域下的電子郵件帳戶,但不知道如何調用該函數。
我想任何人都可以通過使用這個普通的php腳本來獲取他/她的網站cPanel電子郵件帳戶。 我正在使用這個腳本來完成我的個人工作,而且工作正常。
<?php
$domain = 'domain';
$username = 'username';
$quota = 'default_quota';
$mails = "/home/".$username."/.cpanel/email_accounts.yaml";
$mail_info = file_get_contents($mails);
$get_domain_mails = explode('account_count:',$mail_info);
foreach ($get_domain_mails as $accounts_email)
{
$acc = explode(' ',$accounts_email);
$m = $acc[1];
$clean = str_replace($m,"",$accounts_email);
$get_data = str_replace("accounts:","",$clean);
$exp_ag = explode("'",$get_data);
foreach ($exp_ag as $brk)
{
$ex = explode("diskquota",$brk);
foreach ($ex as $na)
{
$aex = explode('disk_mtime',$na);
$aarx = explode("diskused",$aex[0]);
foreach ($aarx as $tax)
{
$rexp = explode(":",$tax);
$reaexp = str_replace(" ","",$rexp[1]);
if ($reaexp!="")
{
$lex = explode($quota,$reaexp);
$naex = explode("\n",$lex[0]);
echo $naex[1]."\n";
}
}
}
}
}
?>
的cPanel UAPI listpops應該做的伎倆
UAPI Functions - Email::list_pops
既然你標記PHP,繼承人的PHP例子
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
// List all email addresses that contain "user".
$emails = $cpanel->uapi(
'Email', 'list_pops',
array(
'regex' => 'user',
)
);
參考https://documentation.cpanel.net/display/SDK/UAPI+Functions+-+Email%3A%3Alist_pops
還應考慮Afterlogic的郵局精簡版API它具有很多的功能,包括用於PHP和JS以及REST API。
的REST API指出
GET /account/list
Returns list of users.
Required parameters:
* string token - token
Optional parameters:
* int page - page number of the list. Default value: 1
* int usersPerPage - number of users per page. Default value: 100
* string orderBy - sorting field. Accepted values: email/name/last login
* string searchDesc - search string used for looking up specific account
* string domain - domain
Return: array
Sample request:
http://yourdomain/rest.php/account/list?token=yourToken
curl -X GET -d "token=yourToken" http://yourdomain/rest.php/account/list
Sample response:
"result":
[
{
"Id": 32,
"Email": "[email protected]",
"FriendlyName": "Name"
},
{
"Id": 33,
"Email": "[email protected]",
"FriendlyName": "OtherName"
}
]
http://www.afterlogic.org/docs/webmail-lite/integration-and-development/rest-api#get-/account/list
Afterlogic PHP API將僅列出Afterlogic db中包含的那些帳戶。它只是cPanel的郵件帳戶列表的一個子集。如果你有,比方說,cPanel服務器上的1000個郵件帳戶和用戶使用Afterlogic登錄了其中100個帳戶,只有這100個帳戶將被添加到Afterlogic數據庫。 – Alex 2017-02-14 10:40:17
好主意,但如果你已經安裝了自己的cPanel自己的服務器上(以root權限),這隻會工作。在共享主機服務器上這不起作用。 – 2014-11-16 13:17:52
是的,這是正確的... :) – 2015-07-04 22:44:43
哦,真的嗎?漂浮在我的樂趣....男人..我如何閱讀共享郵件?我很確定我找到了一種方式,即時通過直接從例如'〜/ mail/domain/accountame/cur/*'使用某種php exec,node或curl/fopen。 – blamb 2017-02-14 07:11:16