modoboa - using dovecot virtual mailboxes for gmail style allmail folder

I wanted to have my own webmail with thread/conversation view like gmail and so many mail clients have. I chose RainLoop to achieve this as it supports Thread-View. However, simply turning on thread view does not do the job, because this will only group incoming emails belonging to the same thread but not your own outgoing emails, as they reside in a different folder and for thread-view to work they all need to be in the same folder.

Luckily dovecot which i use as an IMAP server in this setup, has a Virtual Mailbox Plug-In. Don't mistake this for Virtual Users which are needed to create mail accounts without creating linux users for them, that's a different thing. Virtual Mailboxes provides virtual “Folders” inside your IMAP account much like gmail does with its tags rather than folders. Using Virtual Mailboxes we can now create a folder that contains both the INBOX Mails as well as the sent mails belonging to threads that have also messages in the INBOX which in the end resembles prettymuch waht gmail provides with its conversation view.

the following instructions are based on a mailserver that has been set up using Modoboa. If you have set up dovecot yourself or used a different package to configure it, especially the “separator” might vary, and you need to adjust it to your environment. It is always wise to read the documentation to know what you are doing. Also check the contents of your log files to see what's failing.

first we need to create a namespace. on my server I've created a file /etc/dovecot/conf.d/11-virtual.conf with the following contents:

namespace inbox {
  separator = .
mail_plugins = $mail_plugins virtual
namespace {
  prefix = virtual.
  separator = .
  location = virtual:~/Maildir/virtual

the first namespace inbox is just to add the separator definition to the inbox namespace that was defined in 10-mail.conf. modoboa leaves the separator field undefined which seems to be equal to using a . as separator. I first set it to / which is recommended but it broke compatibility to the modoboa provided (simple) webmail, so i changed it to a . instead.

next we need to create the physical folders for our virtual directories. for each virtual mailbox we need to create a physical folder, in this case a subfolder of ~/Maildir/virtual which needs to contain the definition of what should be inside. this is done by writing the filter definition into a file called dovecot-virtual inside the respective folder.

on modoboa I created these folders (for an email user account with the address


and in both these folders i created a dovecot-virtuat file:



  inthread refs x-mailbox INBOX

this is by the way taken 1:1 from the manual of dovecot-virtual. the first one creates a virtual mailbox that contains just all emails, the second one creates a virtual mailbox that creates all emails that are part of a thread which has at least one message stored in the INBOX which is effectively what we want for our thread view.

once this is all done, dovecot needs to be restarted (or maybe reloading is enough). Now the thread-view of RainLoop shows all all mails, including sent mails, for each thread, if you are using the newly created virtual.INBOX folder.

by the way: RainLoop also works with the / separator, so if you don't have modoboa or if you don't care about modoboa's webmail you can also use the / separator instead of a .