driver = PH_SQL_DRIVER
default_pass_scheme = CRYPT
connect = host=PH_SQL_SERVER_ADDRESS port=PH_SQL_SERVER_PORT dbname=PH_VMAIL_DB_NAME user=PH_VMAIL_DB_BIND_USER password=PH_VMAIL_DB_BIND_PASSWD

# Required by doveadm tools which require to list all mail users.
iterate_query = SELECT username AS user FROM mailbox

password_query = SELECT mailbox.password, mailbox.allow_nets \
        FROM mailbox,domain \
       WHERE mailbox.username='%u' \
             AND mailbox.enable%Ls%Lc=1 \
             AND mailbox.active=1 \
             AND mailbox.domain=domain.domain \
             AND domain.backupmx=0 \
             AND domain.active=1

user_query = SELECT \
            LOWER('%u') AS master_user, \
            LOWER(CONCAT(mailbox.storagebasedirectory, '/', mailbox.storagenode, '/', mailbox.maildir)) AS home, \
            CONCAT(mailbox.mailboxformat, ':~/', mailbox.mailboxfolder) AS mail, \
            CONCAT('*:bytes=', mailbox.quota*1048576) AS quota_rule \
        FROM mailbox,domain \
       WHERE mailbox.username='%u' \
             AND mailbox.enable%Ls%Lc=1 \
             AND mailbox.active=1 \
             AND mailbox.domain=domain.domain \
             AND domain.backupmx=0 \
             AND domain.active=1
