diff --git a/.cvsignore b/.cvsignore index 23e60ef..7ab5a7f 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1 +1,2 @@ supervise +tmp diff --git a/lib/Qpsmtpd/Transaction.pm b/lib/Qpsmtpd/Transaction.pm index a05453c..0ce8db9 100644 --- a/lib/Qpsmtpd/Transaction.pm +++ b/lib/Qpsmtpd/Transaction.pm @@ -65,7 +65,6 @@ sub add_header_line { sub body_write { my $self = shift; my $data = shift; - #$self->{_body} .= shift; unless ($self->{_body_file}) { -d "tmp" or mkdir("tmp", 0700) or die "Could not create dir tmp: $!"; $self->{_filename} = "/home/smtpd/qpsmtpd/tmp/" . join(":", time, $$, $transaction_counter++); @@ -76,7 +75,12 @@ sub body_write { seek($self->{_body_file},0,2) unless $self->{_body_file_writing}; $self->{_body_file_writing} = 1; - $self->{_body_file}->print(ref $data eq "SCALAR" ? $$data : $data); + $self->{_body_file}->print(ref $data eq "SCALAR" ? $$data : $data) + and $self->{_body_size} += length (ref $data eq "SCALAR" ? $$data : $data); +} + +sub body_size { + shift->{_body_size} || 0; } sub body_resetpos { diff --git a/log/.cvsignore b/log/.cvsignore index 23e60ef..f27c43f 100644 --- a/log/.cvsignore +++ b/log/.cvsignore @@ -1 +1,2 @@ +main supervise diff --git a/plugins/spamassassin b/plugins/spamassassin index 39329ab..0034f45 100644 --- a/plugins/spamassassin +++ b/plugins/spamassassin @@ -23,6 +23,8 @@ sub register { sub check_spam { my ($self, $transaction) = @_; + return (DECLINED) if $transaction->body_size > 500_000; + my $remote = 'localhost'; my $port = 783; if ($port =~ /\D/) { $port = getservbyname($port, 'tcp') }