

Dovecot v1.1 quota
==================


Dovecot v1.1 has different quota configuration. You can also get it as a quota-rewrite patch for v1.0 [None]. The configuration is split into multiple settings: 
First you have the actual quota backend configuration. This includes the backend name and its parameters, if there are any. For example: 

---%<-------------------------------------------------------------------------
plugin {
  quota = maildir
}
---%<-------------------------------------------------------------------------



Quota rules
===========


Quota rules configure the actual quota limits. The syntax is: 

---%<-------------------------------------------------------------------------
quota_rule = <mailbox name>:<limit configuration>
#quota_rule2 = ...
#quota_rule3 = ..etc..
---%<-------------------------------------------------------------------------

* as the mailbox name configures the default limit, which is applied on top of a mailbox-specific limit if found. So for example: 

---%<-------------------------------------------------------------------------
quota_rule = *:storage=1G
quota_rule2 = Trash:100M
---%<-------------------------------------------------------------------------

This means that the user has 1GB quota, but when saving messages to Trash mailbox it's possible to use up to 1,1GB of quota. The quota isn't specifically assigned to Trash, so if you had 1GB of mails in Trash you could still save 100MB of mails to Trash, but nothing to other mailboxes. The idea of this is mostly to allow the clients' move-to-Trash feature work while user is deleting messages to get under quota. 
* can't be used as a generic wildcard in mailbox names, so for example "box*" wouldn't match "boxes". As shown in the above example, the first quota rule is named 'quota_rule' while the following rules have an increasing digit in them. You can have as many quota rules as you want. 


Limit configuration
===================


The following limit names are supported: 

 * *storage*: Quota limit in kilobytes. 
 * *bytes*: Quota limit in bytes. 
 * *messages*: Quota limit in number of messages. This isn't probably very useful. 
 * *backend*: Quota backend-specific limit configuration. 
All of these support also b/k/M/G/T/% suffixes. So storage=100M and bytes=100M both mean the exact same thing. messages=1k also means 1024 messages (not 1000). 
Percents are relative to the default rule. For example: 

---%<-------------------------------------------------------------------------
plugin {
  quota = maildir
  quota_rule = *:storage=1GB
  # 10% of 1GB = 100MB
  quota_rule2 = Trash:storage=10%%
  # 20% of 1GB = 200MB
  quota_rule3 = Spam:storage=20%%
}
---%<-------------------------------------------------------------------------

Note that % is written twice to escape it, because >>%variables<< are expanded in plugin section. >>userdb<< configuration may or may not require this escaping. 
Backend-specific configuration currently is used only with Maildir++ quota backend. It means you can have the quota in Maildir++ format (e.g. "10000000S"). 


Per-user quota
==============


You can override quota rules in your >>userdb<<'s >>extra fields<<. Keep all the global settings in plugin section and override only those settings you need to in your userdb. For example: 

---%<-------------------------------------------------------------------------
plugin {
  quota = maildir
  quota_rule = *:storage=1G
  quota_rule2 = Trash:storage=100M
}
---%<-------------------------------------------------------------------------

Next override the default 1GB quota for users: 

---%<-------------------------------------------------------------------------
# LDAP:
user_attrs = homeDirectory=home,quotaBytes=quota_rule=*:bytes=%$
# MySQL:
user_query = select uid, gid, home, \
  concat('*:bytes=', quota_bytes) as quota_rule \
  from users where userid = '%u'
---%<-------------------------------------------------------------------------



Quota warnings
==============


You can configure Dovecot to run an external command when user's quota exceeds a specified limit. Only the command for the first exceeded limit is executed, so configure the highest limit first. The syntax is: 

---%<-------------------------------------------------------------------------
quota_warning = <limit configuration> <command to run>
#quota_warning2 = ...
#quota_warning3 = ..etc..
---%<-------------------------------------------------------------------------

Limit configuration is the exact same as for rules. Usually you want to use percents instead of absolute limits. 
An example configuration: 

---%<-------------------------------------------------------------------------
plugin {
  quota_warning = storage=95%% /usr/local/bin/quota-warning.sh 95
  quota_warning2 = storage=80%% /usr/local/bin/quota-warning.sh 80
}
---%<-------------------------------------------------------------------------

With the above example when user's quota exceeds 80%, 'quota-warning.sh' is executed with parameter 80. The same goes for when quota exceeds 95%. If user suddenly receives a huge mail and the quota jumps from 70% to 99%, only the 95 script is executed. 
(This file was created from the wiki on 2007-12-11 04:42)
