Well thought would post a quick how to, which appears to work for both 5.0.18 and 6.0 RC1, to get the SA RelayCountry plug in going to so you can score based on which country a email has been relayed through. So here goes :-
1) You will need to install the Perl module IP::Country::Fast which can either be done by grabbing it from your repo or using
Code:
perl -MCPAN -e 'install IP::Country::Fast'
2) You will need to create a new amavis custom configuration file with the following content
Code:
package Amavis::Custom;
BEGIN {
import Amavis::Conf qw(:platform :confvars c cr ca $myhostname);
import Amavis::Util qw(do_log untaint safe_encode safe_decode);
import Amavis::rfc2821_2822_Tools;
import Amavis::Notify qw(build_mime_entity);
}
sub new {
my($class,$conn,$msginfo) = @_;
my($self) = bless {}, $class;
$self; # returning an object activates further callbacks,
# returning undef disables them
}
sub before_send {
my($self,$conn,$msginfo) = @_;
my($all_local) = !grep { !$_->recip_is_local }
@{$msginfo->per_recip_data};
if ($all_local) {
my($hdr_edits) = $msginfo->header_edits;
my ($rly_country) =
$msginfo->supplementary_info('RELAYCOUNTRY');
$hdr_edits->add_header('X-Relay-Countries', $rly_country) if defined $rly_country && $rly_country ne '';
my($languages) = $msginfo->supplementary_info('LANGUAGES');
$hdr_edits->add_header('X-Spam-Languages', $languages)
if defined $languages && $languages ne '';
}
}
1; # insure a defined return write that into /opt/zimbra/conf/amavisd-custom.conf with the permissions zimbra:zimbra read only.
3) Update /opt/zimbra/conf/amavisd.conf.in and add the following line at the end of the file
Code:
include_config_files('/opt/zimbra/conf/amavisd-custom.conf'); this
has to be before the line
Code:
1; # insure a defined return
4) Now enable the actual plugin by unhashing loadplugin Mail::SpamAssassin::Plugin::RelayCountry in /opt/zimbra/conf/spamassassin/init.pre
5) Update /opt/zimbra/conf/spamassassin/salocal.cf and add the following
Code:
add_header all Relay-Country _RELAYCOUNTRY_
5) Now restart amavis using
Code:
su - zimbra
zmamavisdctl restart
6) When you next few emails come in check the headers as your should now see something like
Code:
X-Relay-Countries: US
7) With this new header in place you can now create your own custom rules in /opt/zimbra/conf/spamassassin/local.cf eg.
Code:
header RELAYCOUNTRY_CN X-Relay-Countries =~ /CN/
describe RELAYCOUNTRY_CN Relayed through China
score RELAYCOUNTRY_CN 0.5
Good luck and I hope you find that useful.