mail_location = [color="Magenta"]mbox[/color]:/var/mail/%u
mail_location = [color="Magenta"]maildir:~[/color]/Maildir
# store mail in each user's (an user is actually an e-mail account) home directory, maildir format,
# no ~/Maildir sub-directory is used because this home directory is storing only email.
mail_location = [color="Magenta"]maildir:~[/color]/
connect = host=127.0.0.1 port=3306 user=postfix password=s0m3p4ssWOOrd dbname=postfix
driver = mysql
default_pass_scheme = MD5-CRYPT
password_query = SELECT password,[color="Magenta"]CONCAT('/mail/', maildir) AS userdb_home[/color], '89' AS userdb_uid, '89' AS userdb_gid, NULL as allow_nets FROM mailbox WHERE username = '%u' AND domain = '%d' AND active = '1'
user_query = SELECT [color="Magenta"]CONCAT('/mail/', maildir) AS home[/color], '' as mail, '89' AS uid, '89' AS gid, ROUND ( quota / 1024 ) AS quota FROM mailbox WHERE username = %u AND domain = %d AND active = '1'
/etc/local/virtual/%d/%n
/etc/local/virtual/domain.com/bob
/etc/local/virtual//bob
auth_default_realm=domain.com
password_query = SELECT password,CONCAT('/etc/local/virtual/', maildir) AS userdb_home, '89' AS userdb_uid, '89' AS userdb_gid, NULL as allow_nets FROM mailbox WHERE username = '%u' AND domain = '%d' AND active = '1'
user_query = SELECT CONCAT('/etc/local/virtual/', maildir) AS home, '' as mail, '89' AS uid, '89' AS gid, ROUND ( quota / 1024 ) AS quota FROM mailbox WHERE username = %u AND domain = %d AND active = '1'
mail_location = maildir:~/
ecazamir said:Why don't you use
andCode:password_query = SELECT password,CONCAT('/etc/local/virtual/', maildir) AS userdb_home, '89' AS userdb_uid, '89' AS userdb_gid, NULL as allow_nets FROM mailbox WHERE username = '%u' AND domain = '%d' AND active = '1' user_query = SELECT CONCAT('/etc/local/virtual/', maildir) AS home, '' as mail, '89' AS uid, '89' AS gid, ROUND ( quota / 1024 ) AS quota FROM mailbox WHERE username = %u AND domain = %d AND active = '1'
Code:mail_location = maildir:~/
Dovecot will find user's home directory from the userdb user query, and then will expand maildir:~/ to maildir:/etc/local/virtual/mail.account@domain.com/ at runtime. The home directory is hold by the postfix database, this path is usually relative to the mail root directory (/etc/local/virtual in your case). Depending on postfixadmin config, it will contain path lists including the username and the domain, ie: [user@domain.tld (postfixadmin default), or domain.tld/user if postfixadmin is configured to hold each domain mailboxes into separate directories.
The CONCAT SQL statement above has the role of converting the relative path (userdir/) stored by postfix database to an absolute path (/etc/local/virtual/userdir/).
You should set auth_realms to your list of domains, and the auth_default_realm will hold the domain for which your users don't need to pass the domain along with the username (john.doe instead john.doe@domain.tld) when logging in.
You can find why dovecot can't find mail by enabling debug.
/etc/local/virtual/domain.com/bob
/etc/local/virtual//bob
mail_location = [FILE]/path[/FILE]/%d/%u