Source

iredmail / iRedMail / samples / dovecot / dovecot-sql.conf

Full commit
driver = PH_SQL_DRIVER
default_pass_scheme = CRYPT
connect = host=PH_SQL_SERVER dbname=PH_VMAIL_DB user=PH_VMAIL_DB_BIND_USER password=PH_VMAIL_DB_BIND_PASSWD
# Required by 'doveadm mailbox ...'.
#iterate_query = SELECT username AS user FROM mailbox
password_query = SELECT password FROM mailbox WHERE username='%u' AND active='1'
user_query = SELECT \
    '%u' AS master_user, \
    CONCAT(mailbox.storagebasedirectory, '/', mailbox.storagenode, '/', mailbox.maildir) AS home, \
    CONCAT('*:bytes=', mailbox.quota*1048576) AS quota_rule \
FROM mailbox,domain \
WHERE mailbox.username='%u' \
    AND mailbox.domain='%d' \
    AND mailbox.enable%Ls%Lc=1 \
    AND mailbox.domain=domain.domain \
    AND domain.backupmx=0 \
    AND domain.active=1 \
    AND mailbox.active=1