c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen##
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen## Quota configuration.
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen##
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# Note that you also have to enable quota plugin in mail_plugins setting.
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# <doc/wiki/Quota.txt>
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen##
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen## Quota limits
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen##
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# Quota limits are set using "quota_rule" parameters. To get per-user quota
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# limits, you can set/override them by returning "quota_rule" extra field
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# from userdb. It's also possible to give mailbox-specific limits, for example
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# to give additional 100 MB when saving to Trash:
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainenplugin {
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen #quota_rule = *:storage=1G
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen #quota_rule2 = Trash:storage=+100M
57c78fc3f2d94106b8ef941973b0fb2d52f3d754Timo Sirainen
57c78fc3f2d94106b8ef941973b0fb2d52f3d754Timo Sirainen # LDA/LMTP allows saving the last mail to bring user from under quota to
57c78fc3f2d94106b8ef941973b0fb2d52f3d754Timo Sirainen # over quota, if the quota doesn't grow too high. Default is to allow as
57c78fc3f2d94106b8ef941973b0fb2d52f3d754Timo Sirainen # long as quota will stay under 10% above the limit. Also allowed e.g. 10M.
50ecf65993bff429af04deef6c832deb019c76a5Timo Sirainen #quota_grace = 10%%
7f4fa37676bac8efcf4e2ac706172b1bad779a8aMartti Rannanjärvi
7f4fa37676bac8efcf4e2ac706172b1bad779a8aMartti Rannanjärvi # Quota plugin can also limit the maximum accepted mail size.
7f4fa37676bac8efcf4e2ac706172b1bad779a8aMartti Rannanjärvi #quota_max_mail_size = 100M
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen}
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen##
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen## Quota warnings
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen##
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# You can execute a given command when user exceeds a specified quota limit.
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# Each quota root has separate limits. Only the command for the first
19557f192d37cd54a1a090a8a26d9d47265e4413Aki Tuomi# exceeded limit is executed, so put the highest limit first.
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# The commands are executed via script service by connecting to the named
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# UNIX socket (quota-warning below).
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# Note that % needs to be escaped as %%, otherwise "% " expands to empty.
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainenplugin {
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen #quota_warning = storage=95%% quota-warning 95 %u
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen #quota_warning2 = storage=80%% quota-warning 80 %u
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen}
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# Example quota-warning service. The unix listener's permissions should be
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# set in a way that mail processes can connect to it. Below example assumes
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# that mail processes run as vmail user. If you use mode=0666, all system users
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# can generate quota warnings to anyone.
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen#service quota-warning {
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# executable = script /usr/local/bin/quota-warning.sh
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# user = dovecot
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# unix_listener quota-warning {
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# user = vmail
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# }
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen#}
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen##
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen## Quota backends
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen##
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# Multiple backends are supported:
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# dirsize: Find and sum all the files found from mail directory.
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# Extremely SLOW with Maildir. It'll eat your CPU and disk I/O.
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# dict: Keep quota stored in dictionary (eg. SQL)
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# maildir: Maildir++ quota
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# fs: Read-only support for filesystem quota
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainenplugin {
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen #quota = dirsize:User quota
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen #quota = maildir:User quota
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen #quota = dict:User quota::proxy::quota
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen #quota = fs:User quota
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen}
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# Multiple quota roots are also possible, for example this gives each user
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen# their own 100MB quota and one shared 1GB quota within the domain:
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainenplugin {
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen #quota = dict:user::proxy::quota
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen #quota2 = dict:domain:%d:proxy::quota_domain
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen #quota_rule = *:storage=102400
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen #quota2_rule = *:storage=1048576
c220854499511d9508aa416295e3da1fe1568bfaTimo Sirainen}