To alert users, that are approaching theirs mailbox quota limit you can use built in Dovecot plugin quota_warning.
1. Edit the main Dovecot configuration file:
/etc/dovecot/dovecot.conf
plugin { quota = dict:user::file:/var/vmail/%d/%n/.quotausage sieve=/var/vmail/%d/%n/.sieve # Do not change existing plugins defined above, just add new entries below quota_warning = storage=95%% quota-warning 95 %u quota_warning2 = storage=80%% quota-warning 80 %u quota_warning3 = -storage=100%% quota-warning below %u # user is no longer over quota } service quota-warning { executable = script /usr/local/bin/quota-warning.sh user = vmail unix_listener quota-warning { user = vmail mode = 0600 } }
This will execute defined script /usr/local/bin/quota-warning.sh when user will exceed 80 and 95% of their mailbox space.
2. Create the alerting script:
<code> #!/bin/sh PERCENT=$1 USER=$2 cat << EOF | /usr/libexec/dovecot/dovecot-lda -d $USER -o "plugin/quota=maildir:User quota:noenforcing" From: postmaster@localhost.local Subject: Mailbox size warning Your mailbox is now $PERCENT% full. Please delete old messages. EOF </code>
You may edit the text to better explain required steps to resolve this issue.
HI, thank you for the great tips, however I am receive the alert with blank subject and from address. but the email delivered and sender information is inserted in email body.
There should be no blank line before the From… After you delete it, it will work.
peter
And… there should be a blank line after the Subject
I have made changes to the code reflecting your comment
It doesen’t work for me. What is the .sh file user:group and permissions?