如何使用 cPanel API 访问电子邮件帐户列表? [英] How to access list of email accounts with cPanel API?

查看:32
本文介绍了如何使用 cPanel API 访问电子邮件帐户列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

cPanel 是我们在服务器上安装的 Web 服务器管理应用程序.它有一个基于 XML/JSONPHP API,我们要使用它来访问数据,例如所有电子邮件帐户的列表.这个系统巨大,我找不到答案这任何地方.有谁知道如何使用 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?

我需要的功能是 listpopswithdisk (docs here) 列出给定域下的电子邮件帐户,但不知道如何调用此函数.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆