imapログインした時にメールのルートディレクトリはどこを見ているか

maildirに配送したというログがあるのに、telnetからimapログインしたけど受け取っているはずのメールがなかった。
調べた結果、imapログインした時に見ているメールのルートディレクトリが別のところみてた。(x select inboxするとmaildir一式作成するんだね...)

環境

imapログインした時に見ているメールのルートディレクトリは、/etc/dovecot/dovecot-sql.conf.ext の usedb に書いている homeカラムかと思ったら
/etc/dovecot/conf.d/10-mail.conf にある mail_location を見ていたのでした。

なのでpostfixが配送しているディレクトリがdovcotからルートディレクトリになるようmail_locationを変更します。

mail_location = maildir:/home/virtual/%d/%n

(userdbではuidとgidだけ返せばいいってことっぽい。)

ちなみに/etc/postfix/vmailbox.mysql

query = select CONCAT(domain, '/', name, '/') from anonymous_mailboxes where name = '%u' AND domain = '%d'

公式ドキュメントを眺めた

http://wiki2.dovecot.org/VirtualUsers/Home
homeカラムではなくてmailカラムにルートディレクトリのパスを返していればmail_locationを上書きしてくれるっぽい。
とりあえず、今の環境では特異なディレクトリ名になることはないのでmail_locationに直書きでいいや。

# userdb query to retrieve the user information. It can return fields:
#   uid - System UID (overrides mail_uid setting)
#   gid - System GID (overrides mail_gid setting)
#   home - Home directory
#   mail - Mail location (overrides mail_location setting)