mjl- / mox

modern full-featured open source secure mail server for low-maintenance self-hosted email
https://www.xmox.nl
MIT License
3.63k stars 107 forks source link

Support for virtual folders #210

Open bohwaz opened 1 month ago

bohwaz commented 1 month ago

Dovecot has support for virtual folders. It doesn't seem that mox has it, I couldn't find in the documentation.

A virtual folder is a folder that appear to clients as a normal folder, but its contents come from other "real" folders, only returning messages matching the IMAP SEARCH query used.

https://doc.dovecot.org/2.3/configuration_manual/virtual_plugin/

This allows for example to have a "All messages" folder, or for me I have a "flagged" folder, containing flagged messages from all folders.

mjl- commented 1 month ago

Hi @bohwaz! Mox indeed does not currently support virtual folders and there are currently no plans to add support (I just haven't thought about or needed the feature). Some mail clients probably implement this feature client-side, but I can see the appeal of having it implemented server-side.

To implement this in mox, we would have to be able to configure/create virtual folders, with some kind of settings/expressions (all messages, messages with certain flag, ...), and handle all operations on such virtual folders (list/search messages, synchronize mailbox) by applying those filters instead of just filtering on mailbox id. There is a risk that the storage layer can't efficiently handle some of those queries, or that metainformation is not available (e.g. for synchronizing such virtual folders, where we need to keep track of versioning when adding/removing/updating messages).

I won't have time to work on this any time soon. But I could give some pointers if you're interesting in trying to implement it.

bohwaz commented 1 month ago

I think that what is most needed in this function is:

filtering on flagged messages can be done on the client side on top of the virtual folder.