Project:Infrastructure/Developer E-Mail/Sieve Example

From Gentoo Wiki
Jump to: navigation, search

Incoming mails will be forwarded to sieve after creation of

FILE ~/.forward~/.forward for Sieve usage
| "/usr/libexec/dovecot/deliver"

Define the filter rules in

FILE ~/.dovecot.sieve~/.dovecot.sieve example file usage
require ["fileinto", "envelope", "imap4flags", "mailbox"];
# mailbox is required to create folders if they do not exist
# refresh the folder list in your IMAP client and subscribe new folders

# Spam filter
# X-Spam-Score: 5.
# X-Spam-Level: *****
if exists "X-Spam-Flag" {
		if header :contains "X-Spam-Level" "*****" {
		  fileinto :create "spam";
		    addflag "\\seen";
		stop;
		}
}

# bugs
if envelope :is "from" "bugzilla-daemon@gentoo.org" {
  fileinto :create "INBOX.bugs";
}

# test
if header :is "subject" "test" {
  fileinto :create "INBOX.test";
}

# commits
elsif header :contains "List-Id" "gentoo-commits.gentoo.org" {
#addflag "\\Seen";
 fileinto :create "INBOX.list.g-commits";
}
# core ML
elsif header :contains "List-Id" "gentoo-core.gentoo.org" {
 fileinto :create "INBOX.list.g-core";
}

# announce ML
elsif header :contains "List-Id" "gentoo-dev-announce.gentoo.org" {
 fileinto :create "INBOX.list.g-dev-announce";
}

# catchall ML
elsif header :contains "List-Id" "gentoo.org" {
 fileinto :create "INBOX.list.gentoo";
}

Test your configuration by sending a mail with the subject "test" to yourself and monitor ~/.dovecot.sieve.log

The subfolder INBOX.test will be created automatically, but you may have to subscribe it in your mail client.