The Courier IMAP server

Courier-IMAP: IMAP keywords implementation

This white paper describes how Courier-IMAP implements IMAP keywords. This document is provided for informational purposes only.


Courier-IMAP is a maildir-based IMAP server. The reader is presumed to know how maildirs work.

There are five pre-defined flags that may be set on each message in an IMAP folder: \Seen, \Answered, \Draft, \Deleted, and \Flagged. An IMAP server may also optionally offer the ability to set arbitrary client-defined flags for any message.

Implementation Requirements

Implementation Details

The rest of this document describes the technical keyword implementation. This is a short summary of the implement issues that should be understood when using IMAP keywords with Courier-IMAP.

Data storage

A new subdirectory, courierimapkeywords, is created in the maildir. It stores keyword-related data.

The file courierimapkeywords/:list contains a "stable, known list" of all keywords sets for all messages. It is, essentially, a list of the base filenames of each message in the cur directory that has keywords, without the ":2," suffix, and any message flags. Messages without any set keywords are not listed in this file.

Additional files may also exist in this subdirectory, named either .N.file, or file. file is the base filename of a message, while "N" is a numeric value.

The list of keywords set for all messages is obtained by reading the contents of courierimapkeywords according to the process described below.

Updating keywords

A keywords set for a message may be updated as follows:

Reading keywords

First, a list of all messages present in new and cur is obtained. Then: