Postfix + Dovecot + DomainQuota

Hello.

I'm searching for a tutorial/info on how to add quota for a domain in dovecot-sql. I will be grateful for any information.

Regards.
 
Hi :)

I use
OS - FreeBSD 10.2-RELEASE
MTA - Postfix 2.11.6,1
MDA - Dovecot - 2.2.18
Database - MySQL 5.6.26

domain - mydomain.lan
user - user@mydomain.lan


What iI want ?
quota for domain
quota for per user

Info
All information about mydomain and users in MySQL

What iI do and about problem
Config quota (dict + mysql)
Database create Postfixadmin 2.3.7

Code:
# grep -v '^ *\(#.*\)\?$' dovecot-sql.conf
driver = mysql
connect = host=localhost dbname=postfix user=postfix password=invision127
default_pass_scheme = CRAM-MD5
password_query = SELECT username, domain, password FROM mailbox WHERE username = '%u' and domain = '%d' and active='1'
user_query = SELECT '/var/spool/mail/%d/%u' AS home, 'maildir:/var/spool/mail/%d/%u' AS mail, 1983 AS uid, 1983 AS gid, CONCAT('*:bytes=', domain.maxquota*1048576) AS quota_rule, CONCAT('*:bytes=', mailbox.quota) AS quota2_rule FROM mailbox, domain WHERE username = '%u' AND domain.domain = '%d' AND domain.active = '1'

- - -

In last year, iI used version Dovecot 2.2.13 and dovecot using operator "UPDATE" for changing quota field in MySQL base

mysql.log in real time

-----------------
Code:
Connect  postfix@localhost on postfix
Query  SELECT bytes FROM quota2 WHERE username = 'user@mydomain.lan'
Query  SELECT bytes FROM quota2 WHERE username = 'user@mydomain.lan'
Query  BEGIN
Query  UPDATE quota2 SET bytes=bytes+2570,messages=messages+1 WHERE username = 'user@mydomain.lan'
Connect  postfix@localhost on postfix
Query  BEGIN
Query  UPDATE domain SET quota=quota+2570 WHERE domain = 'mydomain.lan'
Query  BEGIN
Query  UPDATE quota2 SET bytes=bytes+1723,messages=messages+1 WHERE username = 'user@mydomain.lan'
Connect  postfix@localhost on postfix
Query  BEGIN
Query  UPDATE domain SET quota=quota+1723 WHERE domain = 'mydomain.lan'
Query  UPDATE quota2 SET messages=messages+1 WHERE username = 'mydomain.lan'
Quit
-----------------

What now ?
Now iI build new server and using in latest version Dovecot 2.2.19 and dovecot now using method DELETE/INSERT for update quota field in MySQL base
Why method DELETE/INSERT what bad use UPDATE operator, tell me please ?

mysql.log in real time

Code:
Connect  postfix@localhost on postfix
Query  SELECT quota FROM domain WHERE domain = 'mydomain.lan'
Query  SELECT quota FROM domain WHERE domain = 'mydomain.lan'
Query  SELECT messages FROM quota2 WHERE username = 'mydomain.lan'
Query  BEGIN
Query  DELETE FROM domain WHERE domain = 'mydomain.lan'
Query  DELETE FROM quota2 WHERE username = 'mydomain.lan'
Query
INSERT INTO domain (quota,domain) VALUES ('8581','mydomain.lan') ON DUPLICATE KEY UPDATE quota='8581'
Quit

Now dic + mysql doesn’t work in Dovecot 2.2.19, because first execute DELETE operator and remove information from base about mydomain.lan

May be iI must another configuration Dovecot ?
Tell me please, what about this bug and how iI can fix this ?
 
Back
Top