• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Mailbox Sizes - Quick Shell Script

ghazlewood

Basic Pleskian
Recently I've needed to know the size of the largest mailboxes on a Plesk 8 box. After some quick Googling and testing I've worked out the following to email me the top 25 (or however many) mailboxes by size.

Code:
#!/bin/sh

cd /var/qmail/mailnames;
du -hs --block-size=1024K */* | sort -nr | head -25 | mail -s 'Top 25 Mailboxes by Size' [email][email protected][/email]

I'm running this weekly by cron so I have a record. Next step is to make it check the psa database for each domain and only show mailboxes near or over quota. But for now it'll do.

Hope someone else finds this useful.

Cheers

George
 
Hey that was exactly what I was looking for! Thanks very much indeed. I had a feeling someone else might have been here already, thanks for sharing your script.

Cheers

George
 
anyone tried this script? it's working?

i tried as well and i had a MySQL error al line 29 :
if (mysql_num_rows($result) > 0)

so i changed in :

if (@mysql_num_rows($result) > 0)

now when i run the script i have no error but a blank page, is it normal? how can i test if it's working correctly?

Thanx and have a great xmas time!
 
Can somebody repost this script?

Originally posted by mooiesite
you can use my script if you want...
it's in dutch, but you'll figure out

it runs every night and checks all mailboxes.
it checks for >90% mailboxes and for >100% mailboxes
it will copy a new mail directly to a users mailbox.

http://www.mooiesite.nl/mailcheck.txt
 
Hi,

i have a parse error:
Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /home/httpd/vhosts/mydomain.com/httpdocs/check_fullmailbox.php on line 168

and if i comment out line 168 i have 2 Warning too:

Warning: ini_set(): open_basedir restriction in effect. File(0) is not within the allowed path(s): (/home/httpd/vhosts/mydomain.com/httpdocs:/tmp) in /home/httpd/vhosts/mydomain.com/httpdocs/check_fullmailbox.php on line 100

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/httpd/vhosts/mydomain.com/httpdocs/check_fullmailbox.php on line 108


Can you help me to fix this very useful script?

Thanx
 
Ah I should have said I'm running this from cron:

Code:
php -d open_basedir=/var/qmail/mailnames -d safe_mode=0 -f /usr/local/psa/admin/htdocs/mailcheck.php

I run this nightly, it's probably not a good idea to run it from an actual site. Well it won't do any harm but much better to run it from cron anyway.
 
Hi,

i tried via cron bur i still have the parse error on line 168, no one else is in my condition?

thanx
 
Sorry for making you find the bugs Mr.Yes!

Can you try downloading it again? I thought I was tidying up before posting it but it looks like I added a bug.

Cheers

George
 
Hello,

i still have an error with new version:

<b>Warning</b>: mysql_num_rows(): supplied argument is not a valid MySQL result resource in <b>/usr/local/psa/admin/htdocs/mailcheck.php</b> on line <b>108</b>

Thanx for your help
 
Sounds like the query is failing, check that your database connection is working correctly. Did you change the host, username and password for mysql?

Failing that can you try running the SQL through phpMyAdmin and see if it's the query which has a problem?

Cheers

George
 
Hello here is my conf:

PHP:
/* CHANGE ME !
Just change the settings below: 
*/

define("MAILNAMES", "/var/qmail/mailnames/");
// You must set this!
define("DOMAIN", "yourdomain.co.uk");
define("ACCOUNT", "postmaster");
define("FROM", ACCOUNT."@".DOMAIN);
// Uncomment the line below and users will get an email, otherwise only the postmaster (defined above) will get messages
//define("DELIVER_TO_USER",true);
define("LOWER_LIMIT", 90.0); // 90% full - approaching capacity
define("UPPER_LIMIT", 99.9); // 99.9% full - mailbox full
// You must set these!
define("DBHOST", 'localhost');
define("DBUSER", 'admin');
define("DBPASS", 'mypleskpassword');
/* End of config */

As u see i put: localhost, admin and mypleskpassword .. is it correct?
 
Sounds right to me. For my setup here I created a specific user who only has read access to those tables but the plesk admin user should be fine too. Can you try running the SQL in phpMyAdmin?
 
Back
Top