Previously, my server was using MailScanner which allowed the direct addition of SpamAssassin headers into the email’s Mime Header. However, Exim doesn’t handle SpamAssassin the same way and the typically documented technique for adding headers doesn’t work. (Side note: this has nothing to do with cPanel per se, it just so happens this was on a cPanel box which uses Exim (by default) and thought I’d drop that term in here for people searching out a solution on “cPanel installs”.) In this case, I’m using the RelayCountry plugin and I wanted to see the country list that the emails bounced through prior to arriving on my server.
This is done by installing and enabling in your SpamAssassin init.pre file:
There are tons and tons of tutorials out there for installing the RelayCountry plugin, so for the sake of redundancy, I won’t cover that here. Once enabled, processing rules against the list was working fine. I.e. in SpamAssassin’s local.cf, a rule like this was working fine:
header CNTRY_SPAM2 X-Relay-Countries =~ /(SOME_2_LETTER_COUNTRY_CODE_HERE|2ND_2_LETTER_COUNTRY_CODE_HERE|3RD_2_LETTER_COUNTRY_CODE_HERE)/i describe CNTRY_SPAM2 Common Spammer Country Rule 1 score CNTRY_SPAM2 100
And indeed, I’d see in my Mime Headers something to the effect of:
100 CNTRY_SPAM2 Common Spammer Country Rule 1
But, I wanted to see which country codes it actually went through, not that it just happened to trigger our 3 country code list above. If your mail server/scanner software utilizes the headers SpamAssassin generates, as my previous MailScanner install did, then the documentation on every site out there works. One simply adds the line to their SpamAssassin local.cf file:
add_header all Relay-Country _RELAYCOUNTRY_
And you are done! But – Exim doesn’t Relay the Relay-Country header (ha!). In fact, Exim doesn’t relay any of the SpamAssassin headers, really. Exim talks to spamd, gets the results as a “report”, then continues processes utilizing that report (among other things). That is a simple overview, but in essence what is going on. So what one can do is modify that SpamAssassin “report” template and add our country code list there. To do so, add to your SpamAssassin local.cf file the line:
report X-Relay-Countries: _RELAYCOUNTRY_
And viola! The spacing is just a little different than other Mime Headers, but there is our country code list in the “X-Spam-Report” Mime Header (at the bottom in my case). This line spacing difference was acceptable to me. The key code in the above line is the ‘report’ and the ‘_RELAYCOUNTRY_’. One could simply add: ‘report _RELAYCOUNTRY_’ and that would work as well.