View Single Post
Old 11th February 2013, 05:54
Parsec Parsec is offline
Join Date: Jan 2013
Posts: 66
Thanks: 1
Thanked 9 Times in 8 Posts

Well this might help if you are using postfix + courier with maildrop

/etc/postfix/ - change the maildrop line so it includes the quota warning. Add -w 90 (where 90 means 90% full - you can alter this figure) just before the -d vmail bit eg:

flags=DRhu user=vmail argv=/usr/bin/maildrop -w 90 -d vmail ${extension} ..etc

(restart postfix)

Create a simple text message /etc/courier/quotawarn - make it look something like this (don't forget to edit for your preferences):
From: Mail Delivery System <>
To: "Valued Customer";
Subject: Mail quota warning
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 7bit

Your mailbox on the server is now more than 90% full.
To continue to receive mail you must remove some messages from your mailbox. If you should reach 100% of your quota, mail delivery to you will stop. Your quota is displayed in the webmail interface

Thank You
Now check your mailbox directory, after receiving mail there will be 2 files in there. "ispconfig_mailsize" which I have no idea what it's doing (never seems to update when mail is removed) and "maildirsize" which thankfully is what maildrop is looking at. Once the mailbox hits 90% full it will notice and then send the user the message above. It will also add a file to the mailbox directory called "quotawarn".

Now there are a couple of problems here. That quotawarn file never gets deleted - so stays even if the user cleans out the mailbox. This will interfere with future quota warnings. So you could add a little script run by cron say in the middle of the night. The little script would be something like:
find /var/vmail -name 'quotawarn' -exec rm -f {} \;
This won't affect the quotas because if it's still hit the 90% limit, maildrop will simply rewrite that quotawarn file and send them another message.

You could also be a little smart and check up on your users to make sure they are not filling up their mailboxes. Simple, just find the mailboxes that have the quotawarn message. You can do this with a cron as well, you could even make it a little more infiormative, but the most simple thing to execute is:
find /var/vmail -name 'quotawarn' |/usr/bin/mail -s "Server Example - Quota Warnings"
Edit: Oops! I better mention that if you want to be emailed about the quotawarnings you best run the above warning thing before the previous one that shows how to delete them - else there will be no quotawarnings for it to report on :-)

Last edited by Parsec; 11th February 2013 at 05:58.
Reply With Quote