Re: [exim] how to set up RelayCountry

Top Page
Delete this message
Reply to this message
Author: Mike Cardwell
Date:  
To: exim-users
Subject: Re: [exim] how to set up RelayCountry
* on the Thu, Feb 15, 2007 at 11:24:39PM +0900, Kunio wrote:

> Cannot SpamAssassin-RelayCountry be used with Exim4(spamd)?
>
> I want to add X-Relay-Countries header.
> Please help how to set up RelayCountry.
>
>
> <My MTA>
> FreeBSD4.10
> Exim4.62(spamd)
> SpamAssasin3.1.7(ports)
>
> <init.pre>comment out
> loadplugin Mail::SpamAssassin::Plugin::RelayCountry
>
> <local.cf>added bellow
> add_header all Relay-Country _RELAYCOUNTRY_


If you want Spamassassin to be able to add extra headers, you need to
run it from the routers rather than the ACLs. Google for
spamassassin_pipe

If you just want to add the header, you can do it natively in exim:

Stick this in your data acl:

warn set acl_m0 =
     acl        = acl_relay_countries
     condition  = ${if ! eq{$acl_m0}{}}
     message    = X-Relay-Countries: $acl_m0


Create a recursive acl as follows:

acl_relay_countries:
   warn set acl_m3 = ${if eq{$acl_m3}{}{$h_received:}{$acl_m3}}
        set acl_m2 = ${if match{$acl_m3}{\N^[^\[]+\[([^\]]+)\]\N}{$1}{}}
        set acl_m3 = ${sg{$acl_m3}{\N^[^\[]+\[([^\]]+)\](.*)\N}{\$2}}
   warn condition  = ${if match{$acl_m2}{\N^\d{1,3}(\.\d{1,3}){3}$\N}}
        !condition = ${if match_ip{$acl_m2}{+private_networks}}
        set acl_m5 = ${sg{$acl_m2}{\N^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$\N}{\$4.\$3.\$2.\$1.zz.countries.nerd.dk}}
        set acl_m5 = ${lookup dnsdb{txt=<,$acl_m5}{${uc:$value}}{UNKNOWN}}
        set acl_m0 = ${if eq{$acl_m0}{}{$acl_m5}{$acl_m0 $acl_m5}}
   warn !condition = ${if eq{$acl_m2}{}}
        acl        = acl_relay_countries
   accept


I only briefly tested the above but it seems to work.

There should be an obfuscated exim configuration contest.

Mike