Dave's Brain

Browse - Computer Tips - How can I make spam go to an IMAP folder?

Date: 2007nov15
OS: Linux

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

A.  These instructions are specific to RedHat/Fedora/CentOS 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:
dnf 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

Add a comment

Sign in to add a comment
Copyright © 2008-2017, 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.