This documentation is for Dovecot v2.x, see wiki1 for v1.x documentation.

Dictionary quota

The dictionary quota backend supports both storage and messages quota limits. The current quota is kept in a dictionary. Currently (as of 1.0.beta9 and later), the only supported dictionary backend is MySQL.

The plugin parameter format is dict:<quota limits> <dictionary URI>. For example:

plugin {
  # 10MB and 1000 messages quota limit
  quota = dict:storage=10240:messages=1000 mysql:/etc/dovecot-dict-quota.conf
} 

Example dovecot-dict-quota.conf:

connect = host=localhost dbname=mails user=mailuser
table = quota
select_field = current
where_field = path
username_field = username 

Create the table like this:

create table quota (
  path varchar(255) not null primary key,
  username varchar(255) not null,
  current integer
); 

Dictionary proxy server

To avoid each process making a new SQL connection, you can make all dictionary communications go through a dictionary server process which keeps the connections permanently open. (1.0 RC1 and later)

The dictionary server is referenced with URI proxy:<dictionary server socket path>:<dictionary name>. The socket path may be left empty if you haven't changed base_dir setting in dovecot.conf. Otherwise set it to <base_dir>/dict-server. The dictionary names are configured in dovecot.conf. For example:

dict {
  quotadict = mysql:/etc/dovecot-dict-quota.conf
} 

Example quota plugin configuration for this:

plugin {
  quota = dict:storage=10240:messages=1000 proxy::quotadict
}