checkmailquota - script to alert POP/IMAP users near quota

shacker23

Well-Known Member
Feb 20, 2005
263
1
168
After very nearly losing a key customer who lost a lot of important mail when his POP account went over quota, I've been looking for something that would send email alerts to POP account holders when their mailboxes are near quota, and summaries of accounts near quota to the hostmaster. Didn't find anything that seemed to do the job neatly, so wrote a shell script for cPanel systems, available here:

http://hosting.birdhouse.org/scripts/checkmailquota.txt

checkmailquota loops through the home dirs and, for each home, loops through hosted domains. For each domain, loops through mailboxes, recording byte sizes. Compares these sizes to what's listed in the quota file for that mailbox. If usage is within xx% of quota, sends a warning message to that mailbox. At end of script, sends a summary of accounts near quota to postmaster.

When I switched to cPanel, I did so because I was getting tired of writing stuff like this all the time. cPanel has seemed pretty complete, but it seems bizarre to me that a script like this, or equivalent functionality, isn't built into the system (at version 10 no less!) Weird. Anyway, hope someone finds this useful.

If you make modifications or have suggestions, please send them on.
 

shacker23

Well-Known Member
Feb 20, 2005
263
1
168
This script has been revved to v 1.2, and now works on cPanel systems with boxtrapper installed. Also now handles cases where users have deleted their quota files.
 

Damian

Well-Known Member
Oct 1, 2001
108
7
318
There is a script that's included with cPanel.

Under tweak settings look for:

Notifications

* Disable Suspending accounts that exceed their bandwidth limit (will clear all suspensions is disabled)
* Disk Space Usage Warnings
* Email Box Usage Warnings

The wording from this email is ordinary at best but it's functional. The message comes from a host based email address so it may not be suitable to run if you offer reseller based hosting. From memory this script runs at the 80% mark.
 

shacker23

Well-Known Member
Feb 20, 2005
263
1
168
Odd - I have that enabled, have always had it enabled. But neither I nor my customers have ever received autogenerated email quota notifications. So it works on your cPanel systems?

Well, I like the configurability of my script:

- Ability to alter the message text
- Ability to modify layout of the summary message
- Ability to turn/off notifications to POP owners or hostmaster separately
- Ability to customize the checking schedule via crontab
 

shacker23

Well-Known Member
Feb 20, 2005
263
1
168
v 1.3 adds a mailbox count as an FYI, so you know roughly how many mailboxes are handled by your server.
 

electric

Well-Known Member
Nov 5, 2001
789
10
318
Be sure to add this as a "bug" to the bugzilla.cpanel.net system. Let them know that you have developed it and wish the code to be added into the cpanel system...

Eventually (2 years from now?) they might add this functionality.. (or add it to what crappy functionality already exists.)

Be sure to post the bugzilla number here so we can vote for it.

:)
 

Izzee

Well-Known Member
Feb 6, 2004
469
0
166
Thank You!

shacker23 said:
v 1.3 adds a mailbox count as an FYI, so you know roughly how many mailboxes are handled by your server.
Thank you very much for sharing your most useful script with us. Seems logical that cPanel should include something like this and will get my vote if you do as electric suggests.
Thanks again.
 

shacker23

Well-Known Member
Feb 20, 2005
263
1
168
v 1.4 only sends warning messages to users if mail quota usage is over specified threshold but also under 100% -- no point in sending to over-quota accounts since user won't receive them, and the bounces will just be returned to root anyway.

Glad to hear people are finding this useful, thanks.

If you want to vote on it, this is bug #3306 in bugzilla:
http://bugzilla.cpanel.net/show_bug.cgi?id=3306
 
Last edited:

spaceman

Well-Known Member
Mar 25, 2002
513
6
318
shacker23 said:
v 1.4 only sends warning messages to users if mail quota usage is over specified threshold but also under 100% -- no point in sending to over-quota accounts since user won't receive them, and the bounces will just be returned to root anyway.

Glad to hear people are finding this useful, thanks.

If you want to vote on it, this is bug #3306 in bugzilla:
http://bugzilla.cpanel.net/show_bug.cgi?id=3306
Just got my vote. I MASSIVELY agree with your comment "For many of us, over-quota mailboxes continue to be one of the leading support issues."

I only just heard about your script over here: http://forums.cpanel.net/showthread.php?t=43698 and have added some additional comments on what a complimentary script might look like.