-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathps-mailsize.pl
More file actions
33 lines (29 loc) · 828 Bytes
/
ps-mailsize.pl
File metadata and controls
33 lines (29 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env perl
#
# A simple policy-server for postfix which implements a message_size_limit per
# domain.
use strict;
# configuration of domains and limits, default action is OK
my %hashConfig = (
"marco-pc-debian.localdomain" => 75,
"example.org" => 1024,
);
my $action;
my %attr = ();
while( <STDIN> ) {
if( /([^=]+)=(.*)\n/ ) {
$attr{$1} = $2;
} elsif( $_ eq "\n" ) {
$action = "action=OK";
foreach my $domain (keys%hashConfig) {
if( $attr{'recipient'} =~ /${domain}$/ ) {
if( $attr{'size'} > $hashConfig{$domain} ) {
$action = "action=534 message size for this domain is limited to ".$hashConfig{$domain};
}
last;
}
}
print $action."\n\n";
exit( 0 );
}
}