28th Sep2016
Author: Gyro

Prevent duplicate Drafts, Junk, Sent, Trash folders in Dovecot

I've set up a new mail server for a client, and then used imapsync to copy all existing mail from the old server to the new server.

Everything seemed to have run smoothly, but shortly after they started using email via the new server, they had multiple folders for drafts, junk, sent, and trash.

After investigating this a bit, I found out that different mail clients expect different folder names on the server, and dovecot will create them when missing.

This really confused me, as this was not happening on the old server, so why was this now happening on the new server?!

Well, I could have prevented this from happening, if I would have had a look at the old server's configuration.

Turns out, you have to configure "Namespaces" to properly configure folders and possible duplicates.

Below is the configuration that was (and now is) in place. It has to be added to /etc/dovecot/dovecot.conf


namespace inbox {
  type = private
  separator = .
  prefix = INBOX.
  inbox = yes

  mailbox Drafts {
    special_use = \Drafts
    auto = subscribe
  }

  mailbox Junk {
    special_use = \Junk
    auto = create
  }

  mailbox spam {
    special_use = \Junk
    auto = no
  }

  mailbox Spam {
    special_use = \Junk
    auto = no
  }

  mailbox Trash {
    special_use = \Trash
    auto = subscribe
  }

  mailbox Sent {
    special_use = \Sent
    auto = subscribe
  }

  mailbox "Sent Mail" {
    special_use = \Sent
    auto = no
  }

  mailbox "Sent Messages" {
    special_use = \Sent
    auto = no
  }

  mailbox Archive {
    special_use = \Archive
    auto = create
  }

  mailbox "Archives" {
    special_use = \Archive
    auto = no
  }
}

With this configuration you get this setup:

INBOX
INBOX.Drafts
INBOX.Junk
INBOX.Trash
INBOX.Sent

Meaning, the Drafts, Junk, Trash, and Sent folders will reside inside the Inbox. Mail clients wanting to be different will have their special folder names mapped to the "one and only" folder of that type, such as iPhone's "Sent Messages" being the actual "Sent" folder.

I hope this helps anyone facing the same issue. Please leave a comment, if you found another special folder name that should be added to this list.

Enjoy! :)

4020

Keep Me Going
Your Name / Website:
Did you like my post? Buy me a Bitcoffee! 14JX52Li7zTKbyQv2omw4tvu6Bi1KzfHNW



7 Responses to “Prevent duplicate Drafts, Junk, Sent, Trash folders in Dovecot”

  • Hi,
    Thanks for post, it helped me with my setup :)

    In my case, I removed `prefix = INBOX.`, and I had to add
    `
    mailbox TRASH {
    special_use = \Trash
    auto = no
    }
    `
    for the Samsung Android app.

    PS: You have a typo, ` mailbox Sent Mail ` should be ` mailbox “Sent Mail” ` (the quotes)

  • It worked for me :) thanks man!

  • Markus

    Small Error (Missing ” “):

    mailbox “Sent Mail” {
    special_use = \Sent
    auto = no
    }

    • Gyro

      Been on an extended holiday, just now going through all comments… I added the quotes, thank you very much for pointing out the mistake.

  • DJ

    Thanks, exactly what I was looking for.

  • Tobias J

    Hi your solution worked for me (iOS client).
    But now it has no effect.
    My plesk did some updates last week and now its not working anymore.
    Can you pls help me?

    • Gyro

      Hi, I don’t have a plesk install, so I am not sure what the issue may be in your specific case. It may be that the location of the config file has changed. If you found a solution, I would very much appreciate you sharing it here! :)

Leave a Reply

Your email address will not be published. Required fields are marked *

What is 13 + 7 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)