[Mimedefang] How to count recipients in filter_recipient

Benoit Panizzon benoit.panizzon at imp.ch
Tue Apr 16 05:51:50 EDT 2013


The situation:

Recipients have different SpamAssassin Settings:

Recipeint A => "NO FILTERING";
Recipient B => "REJECT SPAM";

Now an email arrives
mail from:<sender>
rcpt to:<Recipient A>
rcpt to:<Recipient B>

Now if this is an email that will be handled as spam, we have the problem, 
that Recipeint A does want to receive that email and Recipient B want us to 
reject it during SMTP Handshake.

We could:
Accept the Email and deliver it only to Recipient A.

Problem: If it was a false positive, that sender does not know it was not 
delivered to Recipient B. His Maillog will tell him it was successfully 
delivered. => NoGo.

We could:
Reject that email: Recipient A will complain that we filtered the email even 
though his settings tell us not to do so. = NoGo.

We only accept those recipients which have identical anti-spam settings and 
tempfail the others, forcing the sending MTA to resent them in a separate 
session. So we can then handle that session according the users settings.

sub filter_sender {
  $rcpt_count = 0;
  return ('CONTINUE',"ok");

sub filter_recipient {
  if ($rcpt_count eq 0) {
    my $filterrule = &getspamsettings($recipient);
  } else {
    return ('TEMPFAIL', "Too many Recipients") if ($rcpt_count > 50);
	return ('TEMPFAIL', "Different Spam Setting, please resend separately") if  
($filterrule != &getspamsettings($recipient));
  return ('CONTINUE',"ok");

Well, this is the basic idea. Please ignore the syntax errors :-), I just 
started with the $rcpt_count in my code. Unfortunately filter_sender and 
filter_recipient calls are carried to different filter processes. So the 
counter is not reset.

Is there a way to define some sort of over-global variable that is consistent 
for one SMTP session between all of the mimedefang processes?

Kind regards

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