Skip to content
Browse files

dspam, added 'reject_type disconnect' option

  • Loading branch information...
1 parent 54c3770 commit a1ec569b8a275f998de0c19f961f664b9b91039b @msimerson committed May 20, 2012
Showing with 35 additions and 6 deletions.
  1. +22 −6 plugins/dspam
  2. +13 −0 t/plugin_tests/dspam
View
28 plugins/dspam
@@ -131,12 +131,21 @@ and 1.0 is 100% confidence.
If dspam's confidence is greater than or equal to this threshold, the
message will be rejected. The default is 1.00.
+ dspam reject .95
+
+To only reject mail if dspam and spamassassin both think the message is spam,
+set I<reject agree>.
+
=head2 reject_type
- reject_type [ temp | perm ]
+ reject_type [ perm | temp | disconnect ]
-By default, rejects are permanent (5xx). Set this to temp if you want to
-defer mail instead of rejecting it with dspam.
+By default, rejects are permanent (5xx). Set I<reject_type temp> to
+defer mail instead of rejecting it.
+
+Set I<reject_type disconnect> if you'd prefer to immediately disconnect
+the connection when a spam is encountered. This prevents the remote server
+from issuing a reset and attempting numerous times in a single connection.
=head1 MULTIPLE RECIPIENT BEHAVIOR
@@ -172,7 +181,7 @@ sub register {
$self->{_args} = { %args };
$self->{_args}{reject} = defined $args{reject} ? $args{reject} : 1;
- $self->{_args}{reject_type} = $args{reject_type} || 'perm';
+ $self->{_args}{reject_type} ||= 'perm';
$self->register_hook('data_post', 'dspam_reject');
}
@@ -319,8 +328,8 @@ sub dspam_reject {
# dspam is more than $reject percent sure this message is spam
$self->log(LOGINFO, "fail: $d->{class}, ($d->{confidence} confident)");
- my $deny = $self->{_args}{reject_type} eq 'temp' ? DENYSOFT : DENY;
- return Qpsmtpd::DSN->media_unsupported($deny,'dspam says, no spam please');
+ my $deny = $self->get_reject_type();
+ return Qpsmtpd::DSN->media_unsupported($deny, 'dspam says, no spam please');
}
sub dspam_reject_agree {
@@ -403,4 +412,11 @@ sub get_filter_cmd {
return $default;
};
+sub get_reject_type {
+ my $self = shift;
+ my $deny = $self->{_args}{reject_type} or return DENY;
+ return $deny eq 'temp' ? DENYSOFT
+ : $deny eq 'disconnect' ? DENY_DISCONNECT
+ : DENY;
+};
View
13 t/plugin_tests/dspam
@@ -14,6 +14,7 @@ sub register_tests {
$self->register_test('test_get_filter_cmd', 5);
$self->register_test('test_get_dspam_results', 6);
$self->register_test('test_dspam_reject', 6);
+ $self->register_test('test_reject_type', 3);
}
sub test_dspam_reject {
@@ -111,3 +112,15 @@ sub test_get_filter_cmd {
"get_filter_cmd smtpd, spam" );
};
+sub test_reject_type {
+ my $self = shift;
+
+ $self->{_args}{reject_type} = undef;
+ cmp_ok( $self->get_reject_type(), '==', DENY, "default");
+
+ $self->{_args}{reject_type} = 'temp';
+ cmp_ok( $self->get_reject_type(), '==', DENYSOFT, "defer");
+
+ $self->{_args}{reject_type} = 'disconnect';
+ cmp_ok( $self->get_reject_type(), '==', DENY_DISCONNECT, "disconnect");
+};

0 comments on commit a1ec569

Please sign in to comment.
Something went wrong with that request. Please try again.