Dear all.
I was also wonder how could I notify e-mail users only about their quota limits.
After lot of reading got one solution (currently I’m just configuring it and it is not yet production).
But let me share with you my ideas.
I’ve got Virtualmin GPL on Centos 5.4.
All my e-mail users are system users (not virtual). So every mail user has it home directory where Maildir is stored.
Postfix and Dovecot support Maildir++ format.
http://wiki.dovecot.org/Quota
fs: Filesystem quota.
dirsize: The simplest and slowest quota backend, but it works quite well with mboxes.
dict: Store quota usage in a dictionary (e.g. SQL).
maildir: Store quota usage in Maildir++ maildirsize files. This is the most commonly used quota for virtual users.
Quota plugin for Dovecot should be enabled (http://wiki.dovecot.org/Quota):
protocol imap {
mail_plugins = quota imap_quota
}
protocol pop3 {
mail_plugins = quota
}
In case you’re using deliver:
protocol lda {
mail_plugins = quota
}
imap_quota setting will provide quota status to IMAP clients.
My quota solution is maildir: quota = maildir:user.
Because I’ve got working quota_warning setting in Dovecot only when quota setting was set to maildir:user.
In case of quota setting is FS you should set quota_rule = *:storage=102400 (102400 is the size that Dovecot will calculate as a quota limit and calculate percent for quota_warning setting).
But in this case you’ll have all users with equal mailbox sizes.
If it is acceptable for you it will be enough to set following settings in Dovecot:
quota=fs
quota_rule = *:storage=102400
quota_warning = storage=80%% /usr/local/bin/quota-warning.sh 80
#!/bin/sh
PERCENT=$1
FROM=“postmaster@domain”
qwf="/tmp/quota.warning.$$"
echo "From: $FROM
To: $USER
To: postmaster@domain
Subject: Your email quota is $PERCENT% full
Content-Type: text/plain; charset=“UTF-8”
Your mailbox is now $PERCENT% full." >> $qwf
cat $qwf | /usr/sbin/sendmail -f $FROM “$USER”
rm -f $qwf
exit 0
where 80%% (double %% sign) is percent of quota limit when notification will trigger.
/usr/local/bin/quota-warning.sh - script that will be run when quota hit.
In case if you need different sizes of mailboxes for different users you should use Maildir quota.
In this case quota limit will be stored in file maildirsize of Maildir++ folder (in home folder).
Quota limit format in this file is like:
S,C
After that Postfix and Dovecot will update this file apon receiving and deleting messages like:
52428800S ## My quota setting
6021400 16 ## Server calculated that 6 messages size is 6021400 bytes
1076 1 ## added 1 message with 1076 size to folder
-3142 -3 ## deleted 3 messages total size 3142 bytes
-332400 -2 ## etc
-5074976 -6 ##etc
-611958 -6
3622986 1
332963 1
4564 1
4783 1
332790 1
So all you need is to generate maildirsize file with necessary quota limit in 1st line.
This way Dovecot and Postfix have actual information about messages size.
Now I’m writing a script that will generate limit to maildirsize based on filesystem quota of user.
So when FS quota fom mail user will be changed script should update maildirsize file with new limit.
The problem is how to run that script: cron by root or somehow run script with user priveleges triggered upon quota modification (will be more convinient).
I’ll keep you informed if I’ll manage to make quota notofication.
Or may be you have some ideas for this purpose?
Regards