如何使用cPanel API访问电子邮件帐户列表? [英] How to access list of email accounts with cPanel API?
问题描述
cPanel是我们已安装在服务器上的Web服务器管理应用程序.它具有基于XML/JSON 的巨大,我找不到答案这个在任何地方.有谁知道如何使用cPanel API列出电子邮件帐户?
cPanel is a web server management application that we have installed on our servers. It has a XML/JSON-based PHP API that we want to use to access data such as a list of all email accounts. This system is huge, I could'nt find an answer to this anywhere. Does anyone know how to list email accounts with the cPanel API?
The function I need is listpopswithdisk
(docs here) which lists email accounts under a given domain, but no idea how to call this function.
推荐答案
我认为任何人都可以使用此常规php脚本获取其网站cPanel电子邮件帐户. 我正在使用此脚本进行个人工作,效果很好.
I think anyone can get his/her websites cPanel email accounts by using this normal php script. I am using this script for my personal work and it's working fine.
<?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 API访问电子邮件帐户列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!