Enabling Filtering with Dovecot and Roundcube

After establishing my new mail server I wanted to enable a critical component: mail filtering. I also wanted to test the spam filters to see if they actually worked!

Spam filtering was easy. Using this resource, I sent an email to myself from gmail while monitoring the system logs with:

root@mail:/var/log# watch -n .5 tail -50 syslog

This is the critical line to show that the spam was blocked:

mail amavis[18399]: (18399-06) Blocked SPAM {DiscardedInbound,Quarantined}, [209.85.217.170]:36018 [209.85.217.170] <xxxxxxx@gmail.com> -> <warren@warbel.net>, quarantine: z/spam-z0c8jTW67Lm4.gz, Queue-ID: 6E6E1429C4, Message-ID: <CADwHEq4-8TcFwpPmVw8V2hDWTXHd4jNBP2JAPsvPuG_KgmKEPg@mail.gmail.com>, mail_id: z0c8jTW67Lm4, Hits: 999.9, size: 2180, dkim_sd=20120113:gmail.com, 4444 ms

The mail did not appear in my spam folder.

The second challenge was to enable custom rules. I wanted this mainly to deal with the alerts I was getting from Zabbix. There is a significant amount written about this issue online. I have found the following resources useful, however incomplete. They do not apply to Ubuntu 16.04 as far as I can see.
Link 1
Link 2
Link 3
Link 4
And when, after trying to comprehend and implement all these ideas, resorted to troubleshooting where I found this useful:

Link 5

The critical step that is missed in the above is that sieve must be enabled in /etc/dovecot/15-lda.conf. Where LDA stands for Local Delivery Agent, which is where we want filtering.

The code is:

protocol lda {
# Space separated list of plugins to load (default is global mail_plugins).
mail_plugins = $mail_plugins sieve
}

Again, watching the system logs and after recreating a rule, and testing it, could see managesieve apply the rules.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.