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.