PHP& cPanel-是否可以获取用户帐户中所有电子邮件的总大小 [英] PHP & cPanel - Is there a way to get total size of all emails on a users account
问题描述
我不确定是否可行。用PHP可以找出cPanel服务器上有多少存储电子邮件帐户吗?
I am not sure if this is possible. Is there a way with PHP to find out how much storage email accounts are taking on a cPanel server?
如果没有PHP,有什么方法可以显示并显示一个网站?
If not PHP, is there any way to do it and display on a website?
我已经在目录中获得了磁盘使用的代码...但是不确定如何计算使用的电子邮件存储空间。
I've got the code for disk usage in a directory...but not sure how to calculate email storage used.
注意:
我不要求任何人为此编写代码。如果您有/想要编写它并想要共享它。.我不会抱怨...但是基本上是在尝试找出它是否可能,以及在Google上搜索什么。我一直以这种方式搜索这种措辞,因为它知道如何并且到目前为止都找不到解决方案,这就是为什么我要在这里询问。
Note: I am not asking for anyone to write the code for this. If you have it/want to write it and want to share it..I wouldn't complain...but basically trying to find out if its even possible and maybe what to search for on google or something. I have searched for this wording it every way I know how and can't find a solution as of yet, which is why I am asking on here.
推荐答案
您可以使用PHP类与cPanel的XML-API进行交互
- https://github.com/CpanelInc/xmlapi-php
- http://docs.cpanel。 net / twiki / bin / vief / SoftwareDevelopmentKit / WebHome#cPanel%20%20WHM%27s%20API
- https://github.com/CpanelInc/xmlapi-php
- http://docs.cpanel.net/twiki/bin/vief/SoftwareDevelopmentKit/WebHome#cPanel%20%20WHM%27s%20API
示例PHP代码如下:
<?php
include("xmlapi.php");
$ip = "localhost";
# The access has can be found on your server under WHM's "Setup remote access hash" section or at /root/.accesshash
$root_hash = 'MY HASH CODE HERE';
$xmlapi = new xmlapi($ip);
$xmlapi->hash_auth("MY WHM ACCOUNT USERNAME",$root_hash);
$xmlapi->return_xml(1);
$xmlapi->set_debug(1);
$username = CpanelUsername;
$xmlapi->accountsummary($username);
print $xmlapi->accountsummary($username);
?>
并显示以下内容:
代码:
<accountsummary>
<acct>
<disklimit>200M</disklimit>
<diskused>63M</diskused>
<domain>domain.com</domain>
<email>email@domain.com</email>
<ip>IP</ip>
<maxaddons>100</maxaddons>
<maxftp>100</maxftp>
<maxlst>100</maxlst>
<maxparked>100</maxparked>
<maxpop>100</maxpop>
<maxsql>100</maxsql>
<maxsub>100</maxsub>
<owner>OWNER</owner>
<partition>home</partition>
<plan>PLAN</plan>
<shell>/usr/local/cpanel/bin/noshell</shell>
<startdate>STARTDATE</startdate>
<suspended>0</suspended>
<suspendreason>not suspended</suspendreason>
<suspendtime></suspendtime>
<theme>x3</theme>
<unix_startdate>UNIX_STARTDATE</unix_startdate>
<user>USER</user>
</acct>
<status>1</status>
<statusmsg>Ok</statusmsg>
</accountsummary>
$diskused = $xmlapi->accountsummary->acct->diskused;
print $diskused;
这篇关于PHP& cPanel-是否可以获取用户帐户中所有电子邮件的总大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!