forward_method in policy bank does'nt work

Mark Martinec Mark.Martinec+amavis at
Tue Sep 20 18:55:52 CEST 2011


> I want to redirect all spam sent from a local address to a separate server.
> I use amavis 2.6.4  with a postfix (2.7.0) dual setup.
> I have a policy_bank defined as
> $policy_bank{'GARBAGE'} = {
>                  originating => 1,
>                  forward_method => ' smtp:[]:25',

Leave out the space before smtp.

>                  .....
> };
> Where is the IP of my server handling garbage.
> I use Amavis::Custom and if a certain conditions is meet I load this
> policy_bank
> [...]
> sub checks {
>     Amavis::load_policy_bank( 'GARBAGE' );

> If the condition is meet I would expect the mail to be delivered to the
> server at port 25.  But this does'nt happen.
> What is wrong ? is'nt this possible or should the forward_method be a
> method defined in the postfix

This should work with amavisd 2.7.0, but unfortunately not with 2.6.*.

The reason is that a value of forward_method is copied to
$msginfo->delivery_method *before* checks are made, so when
your custom hook 'checks' is activated, it is too late - it does
replace the forward_method, but not replace its copy in delivery_method().

A workaround is for your custom hook to also explicitly replace the
delivery_method value when it loads a GARBAGE policy bank:

sub checks {  # may be left out if not needed
  my($self,$conn,$msginfo) = @_;
    Amavis::load_policy_bank( 'GARBAGE' );


More information about the amavis-users mailing list