Dave's Brain

Browse - computer tips - move spam to an imap folder

Date: 2007nov15

Q. How can I make spam go to an IMAP folder?

A.

These instructions are specific to Fedora with
Postfix, SpamAssassin and Dovecot
but with tweaks will work on any distro.
We also assume you already have SpamAssassin classifying
the mail.

Make Postfix use Dovecot's local delivery agent.
In file /etc/postfix/main.cf add:

	mailbox_command = /usr/libexec/dovecot/deliver

We had to loosen the permissions on the mail folder.
For deliver to work:

	chmod o+rw /var/spool/mail

Modify SpamAssassin's configuration to place
a simple score in the header.
In file /usr/share/spamassassin/10_default_prefs.cf add:

	add_header all Score _SCORE_

Install the dovecot-sieve package:

	yum install dovecot-sieve

Make Dovecot use Sieve.  Modify file
/etc/dovecot.conf:

	protocol lda {
	    mail_plugins = cmusieve
	}

	plugin {
	    sieve = /etc/sieve/sieve.conf
	}

Create the sieve configuration directory.
It needs to world writable.

	mkdir /etc/sieve
	chmod 777 /etc/sieve

Make file /etc/sieve/sieve.conf that looks like this:

	require ["relational", "comparator-i;ascii-numeric", "fileinto"];

	# if exists "X-Spam-Flag" {
	#	fileinto "spam";
	# }

	if not header :contains "X-Spam-Score" "-" {
		if header :value "ge" :comparator "i;ascii-numeric" "X-Spam-Score" "10" {
			fileinto "spam";
 		}
	}

Restart everything.

More Info:
http://www.davekb.com/search.php?target=spamassassin
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2012, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Advertisements: