exim rewrite subject based on spam
Wednesday, March 26th, 2008 by laneHere is how I got exim to rewrite the Subject header after spamassassin marks a message as spam.
I have an spam ACL in my /etc/exim/exim.conf as follows:
warn spam = spam/defer_ok
add_header = X-Spam-Flag: YES
This will add the X-Spam-Flag: YES header to the email, but I also want to append *** SPAM *** to the Subject :. The way I got this working was to use a filter. Before the begin ACL section of the /etc/exim/exim.conf file, I added the following line:
system_filter = /etc/exim/spam.filter
Then I created a /etc/exim/spam.filter file with the following contents:
if $header_X-Spam-Flag: contains "YES" then headers add "Old-Subject: $h_subject:" headers remove "Subject" headers add "Subject: *** SPAM *** $h_old-subject" headers remove "Old-Subject" endif