[Mimedefang] add_recipient inconsistent results on postfix

Benoit Panizzon benoit.panizzon at imp.ch
Mon Dec 30 11:48:01 EST 2013


Hi David

> Where are you calling action_add_recipient?  It can only be called
> from filter_begin or later.  Could you post your filter (or a suitably
> anonymized version)?

Hmm, maybe you pointed me to the problem. Very strange, that this sometimes work even if it's not supposed to work. Well I guess I could store all changes via Storable and then 
pull them in filter_begin.

I call it from filter_recipient. Well the code is not secret. Here are the part I belive are relevant. We store some variables in a file (to count the number of recipients and 
check if we already had to forward a recipient or if the spam settings are different per recipient etc) in the spool directory as we don't know which MIMEDefang proccess is 
getting which calls.

sub store_vars {
         my($vars) = @_;
         Storable::store($vars, 'vars.db');
}

sub load_vars {
         my $vars = {};
         if(-f 'vars.db') {
                 $vars = Storable::retrieve('vars.db');
         }
         return $vars;
}

sub filter_recipient {
  my ($recipient, $sender, $ip, $hostname, $first, $helo, $rcpt_mailer, $rcpt_host, $rcpt_addr) = @_;
  read_commands_file();
  md_syslog('warning',"DEBUG: Filter Recipient $recipient starting");
  my $vars=&load_vars();

[...]
  my $sth = $dbh->prepare("SELECT id,spamaction,spampoint,virusaction,homeserver,keepFwdCopy,FwdBounceCount,FwdActive,disabled from user where userid = ". $dbh->quote($user) ." 
and domain = ". $dbh->quote($domain));
  $sth->execute();
  my $forwards = $dbh->prepare("SELECT destEMailAddr from alias where srcEMailAddr = ". $dbh->quote($recipient));
  $forwards->execute();
  md_syslog('warning',"DEBUG: FORWARDS: ". $forwards->rows)
[...]
  if (($ref->{'FwdActive'} eq 1) && ($forwards->rows gt 0) && (!(defined($vars->{imp_bounce})))) {
        md_syslog('warning',"DEBUG: We have to forward this email, let's do it");
[...]
                        my ($ruser,$rdomain) = split('@',$recipient);
                        my $srssender = $srs->forward($sender,$recipient);
                        $ruser = "$user+bounce-$srssender";
                        change_sender($ruser);
                        md_syslog('warning',"DEBUG: FORWARDING ====> CHANGING SENDER FROM " . $sender . " TO " . $ruser . " <====");
                        if ($ref->{'keepFwdCopy'} eq 0) {
                                md_syslog('warning',"DEBUG: Deleting Recipient " . $originalrecipient);
                                delete_recipient($originalrecipient);
                        }
                        while (my $aliasref = $forwards->fetchrow_hashref()) {
                                md_syslog('warning',"DEBUG: Adding Recipient " . $aliasref->{'destEMailAddr'});
                                add_recipient($aliasref->{'destEMailAddr'});
                        }
[...]
}


Mit freundlichen Grüssen

Benoit Panizzon
-- 
I m p r o W a r e   A G    -    
______________________________________________________

Zurlindenstrasse 29             Tel  +41 61 826 93 07
CH-4133 Pratteln                Fax  +41 61 826 93 02
Schweiz                         Web  http://www.imp.ch
______________________________________________________



More information about the MIMEDefang mailing list