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/ 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/ 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: