Postfix – Rspamd + amavis

amavisemail-serverpostfixrspamd

Currently I have Postfix with Amavis, Spamassassin, Clamav and all the bells and whistles up and running.

I would like to add RSpamd to the configuration, I don't want to replace Amavis, just keep them running side by side, marking spam messages in subject and adding headers to see which is better in catching spam.

Problem is that Amavis is added as smtpd_proxy_filter with return path.
RSpamd is added as milter. Now running RSpamd by itself is fine, but when I add the Amavis, since the mail is redirected to proxy, the Received header is added, thus RSpamd thinks that all mails are from localhost, skipping some of the checks and not adding headers.

I was thinking about some solutions, but don't know if and how they can be implemented:

  1. Run milter before proxy, didn't work by adding the -o smtpd_milters to master.cf
  2. Tell amavis not to add the Received header
  3. Tell RSpamd to skip localhost Received headers and use the one after that

Is any of that achieveable?

Config files here:

My master.cf

My main.cf has these:

smtpd_milters = inet:127.0.0.1:12345
                inet:localhost:11332
non_smtpd_milters = inet:127.0.0.1:12345
milter_default_action = accept
milter_content_timeout = 30s

Port 12345 for DKIM and 11332 for RSpamd

Thanks

Best Answer

Been in similar situation a few years ago. You can actually remove unnecessary Received: header by adding via master.cf -o header_checks=pcre:/etc/postfix/remove_received.pcre to your smtpd that is receiving mail back from Amavis (probably 127.0.0.1:25 instance, but this depends on where your Amavis forwards filtered mail).

The PCRE in the remove_received.pcre looks like this:

/^Received: from server.my.domain \(\[127.0.0.1\]\).*/ IGNORE

Please note backslash escaping of brackets that would otherwise be interpreted as grouping operators. You may also need to add localhost as additional line depending on how your Amavis connects and introduces itself.

Related Topic