Tip of the Day: Child-folder-only IMAP folders
Maybe this is actually documented somewhere, but I had trouble finding it even though I have fun reading through RFCs. So maybe this is actually Dovecot-specific, but it wouldn’t shock me if other IMAP servers behaved the same way.
The problem statement: I wanted to have a folder under my inbox, with subfolders under it, but the parent folder not able to accidentally have mail items in it. So, a structure like:
- INBOX
- Receipts
- Archived
- Still to deal with
- Receipts
Where the “Receipts” folder was only a container of subfolders, but it couldn’t have its own items inside. I could tell that IMAP supported this concept with a \Noselect
attribute that folders could have, but it wasn’t clear to me how to just make a folder like that without specific server configuration to try to set up regular folders that way.
But it actually ended up being simple: When creating the folder, just put the path separator (/
in my case) at the end of the name. I was playing around with a raw IMAP connection trying it, but it turns out that I can just do it in, say, Thunderbird directly by just requesting the new folder name to be “Receipts/
” instead of “Receipts
“.
The only “spec” I could find describing this behavior, in either IMAP 4rev1 or IMAP 4rev2, is the confusing sentence that “If the mailbox name is suffixed with the server’s hierarchy separator character (as returned from the server by a LIST command), this is a declaration that the client intends to create mailbox names under this name in the hierarchy.” That doesn’t seem to make it clear to me that the intent there is for creating mailbox names under that name but not having the mailbox itself have items, but that’s at least how Dovecot 2.3.19.1 seems to handle it so I’m hoping it’s at least somewhat a standard.