Rob's web

Quota

The default quota is unlimited. We can set an amount that vevery mailbox can use.

Our mailserver uses the srv partition which it shares with other services. The max size depends on the number of users and partion size.

Lets go for 250 MB.

Setting quota

Edit 90-quota.conf

# cd /etc/dovecot/conf.d/
# vi 90-quota.conf
plugin {
  quota_rule = *:storage=250M
  quota_rule2 = Trash:storage=+25M
  quota_rule3 = SPAM:ignore

  # LDA/LMTP allows saving the last mail to bring user from under quota to
  # over quota, if the quota doesn't grow too high. Default is to allow as
  # long as quota will stay under 10% above the limit. Also allowed e.g. 10M.
  quota_grace = 10%%

  # Quota plugin can also limit the maximum accepted mail size.
  #quota_max_mail_size = 100M
}

plugin {
  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
  # use some unprivileged user for executing the quota warnings
  user = vmail
  unix_listener quota-warning {
  }
}

Create quota-warning.sh

# cd /usr/local/bin
# vi quota-warning.sh
#!/bin/sh
PERCENT=$1
USER=$2
cat << EOF | /usr/local/libexec/dovecot/dovecot-lda -d $USER -o "plugin/quota=maildir:User quota:noenforcing"
From: postmaster@example.com
Subject: Quota warning

Your mailbox is now $PERCENT% full.
EOF

Links