From previously posts we started using 4 different technologies to stop spam from reaching our server or being scanned by our rules.
But if any spam will reach us those application wont delete them or do anything with them because we don’t want to lost mail that was send from poorly configure mail server – maybe its important one.
If we use postfix with dovecot we could use dovecot to manipulate emails via IMAP protocol. Sieve is the tool we need that will move mails between folder.
Instalation:
#debian/ubuntu apt-get install dovecot-sieve
#vim /etc/dovecot/conf.d/15-lda.conf ... protocol lda { # Space separated list of plugins to load (default is global mail_plugins). mail_plugins = $mail_plugins sieve } ...
#vim /etc/dovecot/conf.d/90-sieve.conf ... sieve_before = /var/mail/SpamToJunk.sieve ...
Almost there:
#vim /var/mail/SpamToJunk.sieve require "fileinto"; if header :comparator "i;ascii-casemap" :contains "X-Spam-Flag" "YES" { fileinto "Junk"; stop; }
Let sieve know about new rules:
sievec /var/mail/SpamToJunk.sieve
Final restart to make it work:
/etc/init.d/dovecot restart
Now if SpamAssassin mark mail as spam it will be move to JUNK folder.
Rest post related to this topic:
Postfix i Dovecot – perfect duo for mail server
Fight against spam part 1 – Postfix SPF
Fight against spam part 2 – Postfix DKIM