[Mimedefang] limit Recipients for auth user
Benoit Panizzon
benoit.panizzon at imp.ch
Fri Nov 27 05:55:52 EST 2015
Hi Roman
> I need to limit the Recipients from to, cc bcc for auth user in the
> filter_recipient procedure .....is this possible? Realy great it
> would be, to get the count for each to, cc, bcc in the part between
Sure it is. From the viewpoint of the SMTP Transfer, rcpt to: does not
distunguish between to, cc or bcc. All are just recipients.
[...]
require Storable;
[...]
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();
my $vars=&load_vars();
my($s_user,$s_domain) = split(/\@/,$SendmailMacros{auth_authen});
my $anonymous=0;
$anonymous = 1 if ($SendmailMacros{auth_authen} eq '');
if(!defined($vars->{imp_rcpt_count})) {
$vars->{imp_rcpt_count}=1;
}
[...]
if ($vars->{imp_rcpt_count} > 10) {
$vars->{imp_rcpt_count}++;
&store_vars($vars);
return ('TEMPFAIL', "Too many recipients: " .
$vars->{imp_rcpt_count}, 452, '4.5.3');
}
$vars->{imp_rcpt_count}++;
&store_vars($vars);
return ('CONTINUE', "ok");
};
I also store the count in a database for the last hour. So I can limit
the number of recipients per hour per authenticated user, and per ip
per hour for non authenticated users. For the later of course the
number is much smaler and the are being tempfailed with: "Please use
SMTP Authentication to send emails to more recipeints".
The vars.db is being stored in the MIMEDefang spoold dir of the email
being processed. So it's not getting mixed up with other emails.
MIMEDefang removes the spool directory after processing, so vars.db is
not left behind.
-Benoît Panizzon-
--
I m p r o W a r e A G - Leiter Commerce Kunden
______________________________________________________
Zurlindenstrasse 29 Tel +41 61 826 93 00
CH-4133 Pratteln Fax +41 61 826 93 01
Schweiz Web http://www.imp.ch
______________________________________________________
More information about the MIMEDefang
mailing list