HomeAboutMailing ListList Chatter /0/0

Dovecot - Correcting Mailhome, Maildir and Sieve folder locations

2020-10-10 by: David White
From: David White 
Since Mike brought up the topic of Dovecot, I thought I'd send this to you
I posted the following to the Dovecot mailing list (twice), but never got a

I'm going to try to spin up a VM with a new, default install of Dovecot
(configured correctly) to try and track this down, but would also value
your insights if any of you have any.

I have Dovecot on Ubuntu 20.04.
I just migrated the server from CentOS 8, and only migrated to the CentOS 8
machine a few months ago off of CentOS 7.
I am pasting `doveconf -n` at the bottom of this email.

Everything is working.
However, I'm trying to clean up warnings in the logs, and just discovered
that I'm not managing home directories properly.
(c/f https://wiki.dovecot.org/VirtualUsers/Home)

This is in the logs:

Jun 28 06:09:50 mail.example.com dovecot:
Error: stat(/var/vmail/example.com/email@example.com/.dovecot.sieve/tmp)
failed: Not a directory

Can I please get a sanity check?
To resolve, I've come up with a bash loop to create a home folder, and fix
the existing structure for each mailbox on the system.
I ran this for 1 of the domains on the system.

for i in */ ; do mv "$i" mail; mkdir "$i"; mv mail "$i"; mv "$i"/.dovecot*
"$i"; done

Then, I would simply edit /etc/dovecot/conf.d/10-mail.conf so that it looks
like this:

mail_home = /var/vmail/%d/%u
mail_location = maildir:/var/vmail/%d/%u/mail

To confirm, should all of the 'hidden' dovecot files be moved to the user's
new home folder like I'm trying to do in the above script?
Or are there other files that I will need to move?

After running that loop above on a test server (don't worry, I would never
do this in production without testing), one of the mailbox's home folder on
the server looks like this:

total 56
drwxr-xr-x   4 vmail vmail  4096 Jun 28 06:19 .
drwx------   6 vmail vmail  4096 Jun 28 06:09 ..
-rw-------   1 vmail vmail    54 Jul  4  2019 .dovecot.lda-dupes
lrwxrwxrwx   1 vmail vmail    21 May 26  2016 .dovecot.sieve ->
-rw-------   1 vmail vmail     0 Oct 17  2016 .dovecot.sieve.log
-rw-------   1 vmail vmail   218 Jul  6  2019 .dovecot.svbin
drwx------ 277 vmail vmail 32768 Jun 28 06:19 mail
drwx------   3 vmail vmail  4096 Feb  2 17:31 sieve

... and connecting to that mailbox over Thunderbird seems to be working
But I want to make sure I'm not missing anything.

Here is my doveconf -n, with identifying information snipped out:

root@mail:# doveconf -n
# (3c910f64b): /etc/dovecot/dovecot.conf
# Pigeonhole version ()
# OS: Linux 5.4.0-39-generic x86_64 Ubuntu 20.04 LTS ext4
# Hostname: {snip}
auth_mechanisms = plain login
mail_location = maildir:/var/vmail/%d/%u
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope encoded-character
vacation subaddress comparator-i;ascii-numeric relational regex imap4flags
copy include variables body enotify environment mailbox date index ihave
duplicate mime foreverypart extracttext
namespace inbox {
  inbox = yes
  location =
  mailbox Drafts {
    auto = subscribe
    special_use = \Drafts
  mailbox Junk {
    special_use = \Junk
  mailbox Sent {
    auto = subscribe
    special_use = \Sent
  mailbox "Sent Messages" {
    special_use = \Sent
  mailbox Spam {
    auto = create
    special_use = \Junk
  mailbox Trash {
    auto = subscribe
    special_use = \Trash
  prefix =
passdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
plugin {
  sieve = file:~/sieve;active=~/.dovecot.sieve
protocols = imap pop3 lmtp sieve
service auth-worker {
  user = $default_internal_user
service auth {
  unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0666
    user = postfix
  unix_listener auth-userdb {
    group = postfix
    mode = 0666
    user = vmail
service lmtp {
  unix_listener /var/spool/postfix/private/dovecot-lmtp {
    group = postfix
    mode = 0666
    user = postfix
ssl = required
ssl_ca =