Notmuch logo

Postfix can be used for delivering mail and Dovecot for making your maildir available using IMAP.

Dovecot Pigeonhole Sieve can be used for filtering incoming mail and index it using notmuch.

  1. Configuration
    1. Configure Postfix to use Dovecot Sieve
    2. Configure Dovecot Sieve to allow running notmuch
    3. Example Sieve configuration
  2. Notes
    1. Postfix file size limit

Configuration

Configure Postfix to use Dovecot Sieve

Set mailbox_command to dovecot deliver:

    postconf -e 'mailbox_command=/usr/libexec/dovecot/deliver -f "$SENDER" -a "$RECIPIENT"'

Configure Dovecot Sieve to allow running notmuch

Example Sieve configuration

Create ~/.dovecot.sieve with the following contents:

    require ["fileinto", "vnd.dovecot.pipe"];
    if header :contains "X-Spam-Flag" "YES" {
        pipe "notmuch" [ "insert", "--folder=.spam", "--create-folder", "+spam" ];
    } elsif anyof (header :matches "From" "notmuch@notmuchmail.org") {
        pipe "notmuch" [ "insert", "--folder=.mailinglist", "--create-folder", "+mailinglist" ];
    } else {
        pipe "notmuch" [ "insert", "+notmuch-insert", "+inbox" ];
    }

Notes

Postfix file size limit

Postfix sets a file size ulimit before executing the mailbox_command. This also affects the notmuch index. Make sure mailbox_size_limit is at least the size of your largest notmuch index files.