Skip to content

Commit

Permalink
Issue #526: Fix dovecot quota warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Kienan Stewart authored and camlafit committed Sep 29, 2023
1 parent 5eac4b3 commit 1f932fd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
13 changes: 11 additions & 2 deletions etc/alternc/templates/dovecot/conf.d/95_alternc.conf
Expand Up @@ -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

Expand All @@ -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
Expand Down
13 changes: 7 additions & 6 deletions src/quota-warning.sh
@@ -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

0 comments on commit 1f932fd

Please sign in to comment.