How to override mail_driver, mail_path, mail_index_path with SQL userdb
Dear all,
I'm migrating from Dovecot 2.3 to 2.4 on Debian 13, only one issue remains: How can i override global mail_driver, mail_path, mail_index_path parameters with a SQL userdb?
I have these lines in dovecot.conf to use maildir format mailbox by default, also
userdb and passdb with mariadb backend. We store mailbox format (e.g.
"maildir", "mdbox", case insensitive) in SQL column mailboxformat
, and
mailbox folder name in mailboxfolder
(e.g. "Maildir", "mdbox", case sensitive).
I tried returning mail_driver
+ mail_path
, or userdb_mail_driver
+
userdb_mail_path
, neither works.
So the question is, what should i return in userdb sql query to override global setting?
Thanks for helping. :)
-------------------------------
mail_driver = maildir mail_path = ~/Maildir mail_index_path = ~/Maildir
sql_driver = mysql mysql 127.0.0.1 { port = 3306 dbname = ... user = ... password = ... }
userdb sql {
iterate_query = ...
query = SELECT
LOWER('%{user | lower}') AS master_user,
LOWER(CONCAT(mailbox.storagebasedirectory, '/', mailbox.storagenode, '/', mailbox.maildir)) AS home,
LOWER(mailbox.mailboxformat) AS mail_driver,
CONCAT("~/", mailbox.mailboxfolder) AS mail_path,
CONCAT(LOWER(mailbox.mailboxformat), ":~/", mailbox.mailboxfolder) AS mail,
CONCAT('*:bytes=', mailbox.quota*1048576) AS quota_rule
FROM mailbox,domain
WHERE ...
}
passdb sql { query = SELECT ... }
-------------------------------
On Sep 3, 2025, at 20:25, Zhang Huangbin <zhb@iredmail.org> wrote:
I'm migrating from Dovecot 2.3 to 2.4 on Debian 13, only one issue remains: How can i override global mail_driver, mail_path, mail_index_path parameters with a SQL userdb?
mail_driver = maildir mail_path = ~/Maildir mail_index_path = ~/Maildir
userdb sql { query = SELECT ..., LOWER(mailbox.mailboxformat) AS mail_driver,
CONCAT("~/", mailbox.mailboxfolder) AS mail_path,
CONCAT(LOWER(mailbox.mailboxformat), ":~/", mailbox.mailboxfolder) AS mail,
CONCAT('*:bytes=', mailbox.quota*1048576) AS quota_rule
FROM mailbox,domain
WHERE ... }
ok, find the answer in Settings Variables[1] and Passwd-file[2] page. Here's the working setting:
mail_driver = %{userdb:mail_driver | default("maildir") | lower} mail_path = %{userdb:mail_path | default("~/Maildir")}
userdb returns mail_driver
and mail_path
.
[1] https://doc.dovecot.org/2.4.1/core/settings/variables.html [2] https://doc.dovecot.org/2.4.1/core/config/auth/databases/passwd_file.html
participants (1)
-
Zhang Huangbin