The below assumes your using mdbox so dirsize or dict:sql will be the fastest. Since we already have sql setup, were going to go with that.
Enabling the Quota Plugin
mail_plugins = $mail_plugins quota
protocol imap {
# Space separated list of plugins to load (default is global mail_plugins).
mail_plugins = $mail_plugins imap_quota
}
plugin {
# SQL backend:
quota = dict:User quota::proxy::quota
quota_rule = *:storage=1024M:messages=100000
quota_rule2 = Trash:storage=+20%%
quota_rule3 = Junk:storage=+20%%
}dict {
quota = mysql:/etc/dovecot/dovecot-dict-mysql.conf
}
The dovecot-dict-mysql.conf file should containe something like this
connect = host=localhost dbname=postfix user=postfix password=postfix
map {
pattern = priv/quota/storage
table = quota
username_field = username
value_field = bytes
}
map {
pattern = priv/quota/messages
table = quota
username_field = username
value_field = messages
}
And lastly, add the following table to your email servers database in mySQL.
CREATE TABLE quota ( username varchar(100) not null, bytes bigint not null default 0, messages integer not null default 0, primary key (username) );