• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

CLI command or SQL query to find the size of a mailbox

Miguel_Tellería

Basic Pleskian
Plesk 12.0.18 on Centos 6.6.

Dear all,

In order to do automate some statistics i would like to have a quick way to see the size the mailboxes.

I know that I could execute a du -shc under /var/qmail/mailnames/<domain>/<mailbox> but for large mailboxes it will take a lot of time.

On the other hand Plesk reports mailbox sizes and occupation very fast (although not always up to date as I have noticed). This is the data that I would like to fetch which is good enough for my purposes.

I have tried the output of /usr/local/psa/bin/mail --info but it doesn't have that value. Is there another way to obtain it?

Regards,

Miguel Telleria
 
[root@ppu12-0 ~]# /usr/local/psa/admin/bin/mailbox_usage --help
Usage: mailbox_usage [--in-blocks]
STDIN should contain a set of '<domain_name> <mailbox_id> <mailbox_name>' strings
STDOUT will contain a set of '<counted_usage> <domain_name> <mailbox_id> <mailbox_name>' strings

[root@ppu12-0 ~]# /usr/local/psa/admin/bin/mailbox_usage --in-block
ppu12-0.demo.pp.plesk.ru 1 admin
5212 ppu12-0.demo.pp.plesk.ru 1 admin
 
Hello IgorG,

I have tried your approach, using mailbox_id to 1 in all lists, since I don't know what mailbox_id is.

It works so far for me, although I always get an enigmatic error: "Unable to parse string: <blank>"

I am trying another approach based on the database and the mn_param table.

SELECT mail.mail_name, domains.name, mn_param.val, mail.mbox_quota FROM mail, mn_param, domains WHERE mail.id=mn_param.mn_id AND mail.dom_id=domains.id AND mn_param.param='box_usage' and mail.mail_name="NAMEBEFORE@" and domains.name="DOMAIN"

I assume that this would also be equivalent.
 
You can find IDs of mailboxes with

mysql> select concat(mail.mail_name,"@",domains.name) as address, mail.id from mail,domains,accounts where mail.dom_id=domains.id and mail.account_id=accounts.id order by address;
 
I want to use the mailbox_usage command.
SQL can now look up mailbox IDs.
How do I actually use the mailbox_usage command?

For example, if I wanted to look up mailadd@example.com and the ID of this email address was 10, would the command look like this?

# /usr/local/psa/admin/bin/mailbox_usage --in-block example.com 10 mailadd
 
How do I actually use the mailbox_usage command?
You have to run the command:

# /usr/local/psa/admin/bin/mailbox_usage --in-block

then type

example.com 10 mailadd

and get something like

2026868 example.com 10 mailadd

in output. More details in help:

# /usr/local/psa/admin/bin/mailbox_usage --help
Usage: mailbox_usage [--in-blocks]
STDIN should contain a set of '<domain_name> <mailbox_id> <mailbox_name>' strings
STDOUT will contain a set of '<counted_usage> <domain_name> <mailbox_id> <mailbox_name>' strings
 
Thanks IgorG!

I was able to get the value by the method you told me. Please tell me one more thing.
What value is returned by this command?
I want to get the mailbox utilization with the CLI, but I get the maximum value for each mailbox with the following command, and even though the mailbox is 100%, the values don't match.

A. /usr/local/psa/bin/mail -i mailadd@example.com | grep 'Mbox quota'
If there is "Unlimited"
B. /usr/local/psa/bin/subscription_settings -i example.com | grep mbox_quota
(If the suffix is KB, multiply by 1024, suffix is MB, multiply 1024000...)

Is the way of thinking wrong?
English may be strange because I use machine translation. Sorry.
 
Back
Top