From Gentoo Wiki
Jump to: navigation, search

The following are sieve scripts that should help manage and organize Gentoo-related mail. This slightly expands upon the example given in the Project:Infrastructure/Developer E-Mail/Sieve Example page. For more information about sieve itself, see the External resources section below.

The master.sieve script is selected as the active script and simply loads the remainder and provides a fallback action. Each rule also issues a stop statement so that further processing of the message doesn't take place.


To set this up, create a directory on called ~/sieve. Within this directory you place each of your sieve scripts (named <scriptname>.sieve). You then point to the master sieve script and tell the LDA to use the sieve scripts using the below:

user $ln -s sieve/master.sieve ~/.dovecot.sieve
user $echo '| "/usr/libexec/dovecot/deliver"' > ~/.forward

Note that mail-client/thunderbird has an extension to manage sieve scripts, however the current version from the Mozilla repository doesn't work - you will need to download a development build from the GitHub repository.

The path separator for folders is ., not /, so a path of INBOX.bugs actually means a folder named bugs that is inside your INBOX.

The scripts

FILE ~/sieve/master.sieve
require ["include", "fileinto"];

include :personal "spam";
include :personal "testing";
include :personal "bugs";
include :personal "lists";
include :personal "aliases";

# Default action
FILE ~/sieve/spam.sieve
require ["envelope", "fileinto", "mailbox"];

if exists "X-Spam-Flag" {
  if header :contains "X-Spam-Level" "*****" {
    fileinto :create "Junk";
FILE ~/sieve/testing.sieve
require ["regex", "mailbox", "fileinto", "variables", "envelope", "subaddress"];

# obviously you may want to disable these at some point
if header :regex "Subject" "another (.*)" {
  fileinto "INBOX.${1}";

if envelope :detail "To" "test" {
  # matches ''
  fileinto :create "INBOX.test";

#if header :contains "From" "" {
#  fileinto :create "INBOX.test";
#  stop;
FILE ~/sieve/lists.sieve
require ["fileinto", "mailbox", "regex", "variables"];

# Gentoo Lists
if header :regex "List-Id" "gentoo-(.*)\.gentoo\.org" {
  fileinto :create "INBOX.list.${1}";
FILE ~/sieve/aliases.sieve
require [

# this will need any new aliases added to the regex match
if not header :is ["To", "CC"] "" {
  if header :regex ["To", "CC"] "(proxy-maint|sci-geo|maintainer-needed).*" {
    if not duplicate {
      fileinto :create "INBOX.proj.${1}";
    } else {  # this is a safeguard for duplicates
      fileinto :create "INBOX.test";
FILE ~/sieve/bugs.sieve
require ["fileinto", "mailbox"];

if allof (
    header "To" "",
    header "From" "") {
  fileinto :create "INBOX.bugs";

External resources