Mailfilter setup with Rspamd 3.1 and ISPConfig

Installation instructions for an opensource email filter with antivirus/antispam, automatic spam/ham training, white/blacklists and allowed dots for IMAP foldernames. Configuration examples for Postfix, Dovecot, Rspamd, ClamAV, Sieve, getmail and Monit.

A correctly installed ISPConfig-server with Rspamd on Ubuntu according to the Perfect Server Setup is required for this tutorial.

Tested with ISPConfig 3.2.7p1 on Ubuntu 20.04.

ISPConfig

System → Server Config → Mail

Setup configuration for…

  • Maildir Format = Maildir,
  • POP3/IMAP Daemon = Dovecot,
  • Mailfilter Syntax = Sieve,
  • Content Filter = Rspamd

Postfix

Check configuration if Postfix is connected to Rspamd

grep 11332 /etc/postfix/main.cf
smtpd_milters = inet:localhost:11332
non_smtpd_milters = inet:localhost:11332

Rspamd

Check if Rspamd is running

netstat -unplet|grep rspamd
tcp    0    0 127.0.0.1:11332    0.0.0.0:*    LISTEN    121    28234475    115131/rspamd: main
tcp    0    0 127.0.0.1:11333    0.0.0.0:*    LISTEN    121    28234485    115131/rspamd: main
tcp    0    0 127.0.0.1:11334    0.0.0.0:*    LISTEN    121    28234480    115131/rspamd: main

Add extended spam headers to each mail for debugging purposes.

Add white/blacklists with multimap.conf to always accept server messages to root

Configure automatic spam/ham learning for moving emails from/to the Junk folder to train Rspamd

ClamAV

Setup ClamAV virus mailfilter for Rspamd to reject viruses

Dovecot

Allow dots for IMAP folder names for Google Mail and Microsoft Exchange comaptibility

getmail

Rewrite “Return-Path” to “Sender Email” to work correctly with Rspamd when fetching mails from remote POP3/IMAP accounts.

Monit

Enable monitoring with Monit to automatically restart Rspamd in case of not running anymore

See also