Issue #526: Fix dovecot quota warnings

This commit is contained in:
Kienan Stewart 2022-10-11 14:19:57 -04:00 committed by Camille Lafitte
parent 5eac4b375d
commit 1f932fd5ec
2 changed files with 18 additions and 8 deletions

View File

@ -300,8 +300,8 @@ plugin {
# Note that % needs to be escaped as %%, otherwise "% " expands to empty.
# quota_warning = storage=95%% /usr/local/bin/quota-warning.sh 95
# quota_warning2 = storage=80%% /usr/local/bin/quota-warning.sh 80
quota_warning = storage=95%% /usr/lib/alternc/quota-warning.sh 95
quota_warning2 = storage=80%% /usr/lib/alternc/quota-warning.sh 80
quota_warning = storage=95%% quota-warning 95 %u
quota_warning2 = storage=80%% quota-warning 80 %u
#quota = maildir
quota = dict:user::proxy::quotadict
@ -317,6 +317,15 @@ plugin {
sieve_dir=~/sieve
}
service quota-warning {
executable = script /usr/lib/alternc/quota-warning.sh
unix_listener quota-warning {
mode = 0660
user = vmail
group = vmail
}
}
# Dictionary can be used by some plugins to store key=value lists, such as
# quota, expire and acl plugins. The dictionary can be used either directly or
# though a dictionary server. The following dict block maps dictionary names to

View File

@ -1,16 +1,17 @@
#!/bin/bash
PERCENT=$1
DOM="`echo $USER | sed -e 's/.*@//'`"
PERCENT="$1"
MAILUSER="$2"
DOM="$(echo "${MAILUSER}" | sed -e 's/.*@//')"
FROM="postmaster@$DOM"
msg="From: $FROM
To: $USER
cat <<EOF | /usr/lib/dovecot/deliver -d "${MAILUSER}" -o "plugin/quota=maildir:User quota:noenforcing"
From: $FROM
To: $MAILUSER
Subject: Your email quota is $PERCENT% full
Content-Type: text/plain; charset=UTF-8
Your mailbox is now $PERCENT% full."
echo -e "$msg" | /usr/sbin/sendmail -f $FROM "$USER"
EOF
exit 0