4
4
The /dictionary/ quota backend supports both *storage* and *messages* quota
5
limits. The current quota is kept in a dictionary. Currently the only supported
6
dictionary backend is MySQL.
8
The plugin parameter format is 'dict:<quota limits> <dictionary URI>'. For
11
---%<-------------------------------------------------------------------------
5
limits. The current quota is kept in a dictionary. The available dictionaries
10
* Flat file (v1.2.alpha3+)
12
The plugin parameter format is:
14
---%<-------------------------------------------------------------------------
16
quota = dict:<quota limits> <dictionary URI>
18
quota = dict:<quota root name>:<user name>:<dictionary URI>
19
---%<-------------------------------------------------------------------------
21
If user name is left empty, the logged in username is used (this is probably
29
---%<-------------------------------------------------------------------------
31
quotadict = mysql:/etc/dovecot-dict-quota.conf
13
35
# v1.0: 10MB and 1000 messages quota limit
14
quota = dict:storage=10240:messages=1000 mysql:/etc/dovecot-dict-quota.conf
16
quota = dict mysql:/etc/dovecot-dict-quota.conf
36
quota = dict:storage=10240:messages=1000 proxy::quotadict
39
quota = dict:user::proxy::quotadict
17
40
quota_rule = *:storage=10M:messages=1000
19
42
---%<-------------------------------------------------------------------------
21
However, *the above example won't really work*. This is because it would
22
require linking all the binaries with MySQL library, which I didn't really want
23
to do. Currently you'll have to do this via the dictionary proxy (see below).
24
Actually the performance is better that way anyway, and I don't really see a
44
The above example uses dictionary proxy process (see below), because SQL
45
libraries aren't linked to all Dovecot binaries.
27
47
Example 'dovecot-dict-quota.conf':
29
49
---%<-------------------------------------------------------------------------
50
# v1.0 and v1.1 only - v1.2 has different configuration
30
51
connect = host=localhost dbname=mails user=sqluser password=sqlpass
32
53
select_field = current
46
67
---%<-------------------------------------------------------------------------
72
---%<-------------------------------------------------------------------------
74
quotadict = mysql:/etc/dovecot-dict-sql.conf
79
quota = dict:user::proxy::quotadict
81
quota = dict:user::file:%h/Maildir/dovecot-quota
83
quota_rule = *:storage=10M:messages=1000
85
---%<-------------------------------------------------------------------------
87
The above SQL example uses dictionary proxy process (see below), because SQL
88
libraries aren't linked to all Dovecot binaries. The file example accesses the
91
Example 'dovecot-dict-sql.conf':
93
---%<-------------------------------------------------------------------------
95
connect = host=localhost dbname=mails user=sqluser password=sqlpass
97
pattern = priv/quota/storage
99
username_field = username
103
pattern = priv/quota/messages
105
username_field = username
106
value_field = messages
108
---%<-------------------------------------------------------------------------
110
Create the table like this:
112
---%<-------------------------------------------------------------------------
114
username varchar(100) not null,
115
bytes bigint not null default 0,
116
messages integer not null default 0,
117
primary key (username)
119
---%<-------------------------------------------------------------------------
121
If you're using PostgreSQL, you'll need a trigger:
123
---%<-------------------------------------------------------------------------
124
CREATE OR REPLACE FUNCTION merge_quota() RETURNS TRIGGER AS $$
126
IF exists(SELECT 1 FROM quota WHERE username = NEW.username) THEN
127
UPDATE quota SET bytes = bytes + NEW.bytes,
128
messages = messages + NEW.messages
129
WHERE username = NEW.username;
137
CREATE TRIGGER mergequota BEFORE INSERT ON quota
138
FOR EACH ROW EXECUTE PROCEDURE merge_quota();
139
---%<-------------------------------------------------------------------------
48
141
v1.0 Inaccuracy problems
49
142
------------------------
51
With Dovecot v1.1 quota is tracked accurately. With v1.0 you may have a
144
With Dovecot v1.1+ quota is tracked accurately. With v1.0 you may have a
54
147
If two IMAP clients do an expunge at the same time, the quota is reduced twice
71
164
The dictionary server is referenced with URI 'proxy:<dictionary server socket
72
165
path>:<dictionary name>'. The socket path may be left empty if you haven't
73
166
changed 'base_dir' setting in 'dovecot.conf'. Otherwise set it to
74
'<base_dir>/dict-server'. The dictionary names are configured in dovecot.conf.
167
'<base_dir>/dict-server'. The dictionary names are configured in
168
'dovecot.conf'. For example:
77
170
---%<-------------------------------------------------------------------------
79
quotadict = mysql:/etc/dovecot-dict-quota.conf
81
---%<-------------------------------------------------------------------------
83
Example quota plugin configuration for this:
85
---%<-------------------------------------------------------------------------
88
quota = dict:storage=10240:messages=1000 proxy::quotadict
90
quota = dict proxy::quotadict
91
quota_rule = *:storage=10M:messages=1000
93
---%<-------------------------------------------------------------------------
95
(This file was created from the wiki on 2008-06-20 04:42)
172
quota = mysql:/etc/dovecot-dict-quota.conf
173
expire = mysql:/etc/dovecot-dict-expire.conf
175
---%<-------------------------------------------------------------------------
177
(This file was created from the wiki on 2009-01-05 04:42)