Log SpamAsssassin X-Spam-Status (rules and scores) into amavis log file

Dominic Raferd dominic at timedicer.co.uk
Fri Jul 19 15:55:02 CEST 2019


On Fri, 19 Jul 2019 at 14:06, mabi <mabi at protonmail.ch> wrote:

> Hello,
>
> I would like to log the typical X-Spam-Status mail header which gets added
> by SpamAssassin to a mail into the amavis log file in order to track the
> rules and their scores which gets triggered by ham and spam mails.
>
> Is this somehow possible with Amavis?
>

The X-Spam-Status header is added by Amavis itself. With postfix (and
postfix-pcre) you could log it thus (untested):

/etc/postfix/master.cf:
...
# this smtpd receives emails being re-injected into postfix by amavis
127.0.0.1:10025 inet n   -       y       -       -       smtpd
...
  -o cleanup_service_name=cleanup_post_amavis
...
cleanup_post_amavis unix  n       -       y       -       0 cleanup
...
  -o header_checks=pcre:/etc/postfix/log_spam_status.pcre
...

/etc/postfix/log_spam_status.pcre:
/^(X-Spam-Status: .*)$/ INFO ${1}

Note that due to a feature (bug?) any 'X-Spam-Status' line in a quarantined
email is stripped out by Amavis when the email is released (using
amavisd-release) and so will not be seen by postfix. My workaround is to
rename any such header in the quarantined email before releasing it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.amavis.org/pipermail/amavis-users/attachments/20190719/3a354c0c/attachment.html>


More information about the amavis-users mailing list