custom quarantine help

Quanah Gibson-Mount quanah at
Sat May 21 02:34:07 CEST 2011

I have the following custom module that does not do quite what I want it to 
do yet.  I know I need to tweak the "sender" and "recipient" sections, but 
I'm not quite sure what they need to be tweaked to.  Previously, when we 
patched amavis directly, we could trigger a quarantine of any mail a user 
sent or received by setting amavisQuarantineTo on their user object in 
LDAP.  We are now trying to do this the correct way via a custom module. 
However, when I put the module in place, it quarantines all email 
regardless of sender/recipient, rather than only the targeted user(s), and 
it puts the quarantine on disk rather than sending them to the specified 
quarantine account.  Module is as follows, pointers appreciated:

package Amavis::Custom;
use strict;
use warnings;
no warnings qw(uninitialized redefine);

  import Amavis::Conf qw(:platform ca);

# invoked at child process creation time;
# return an object, or just undef when custom checks are not needed
sub new {
  my($class,$conn,$msginfo) = @_;
  my($self) = bless {}, $class;

  my($ccat_sub) = 0;
  my(@recips) = map { $_->recip_addr } @{$msginfo->per_recip_data};
  if (Amavis::Lookup::lookup(0,$msginfo->sender,
        @{ca('archive_quarantine_to_maps')})) {
    $ccat_sub = 3;  # sender quarantine
  } elsif (grep { Amavis::Lookup::lookup(0,$_,
         @{ca('archive_quarantine_to_maps')}) } @recips) {
    $ccat_sub = 2;  # recipient quarantine
  if ($ccat_sub > 0) {
    for my $r (@{$msginfo->per_recip_data}) {
  $self;  # returning an object activates further callbacks,
          # returning undef disables them


Quanah Gibson-Mount
Principal Software Engineer
Zimbra, Inc
Zimbra ::  the leader in open source messaging and collaboration

More information about the amavis-users mailing list