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!
4037