This adds the extensibility to customize the prepended signature in the
Subject via the config. It also includes the ability to include the score
in the signature as well as include a space in the signature. The issue of
the space comes as the config parsing requires "mod 2" and I was lazy.
I propose in the TODO the ability to clock the time it takes for spamd to
scan an email. A month or so ago there was a thread about this and I forgot
I had such a mechanism in my spamassassin plugin. Rather than pollute this
patch with its already suspect sprintf and sed. I can submit that as a
subsequent patch.
--- qpsmtpd-0.32.orig/plugins/spamassassin 2006-02-26
06:22:16.000000000 -0600
+++ qpsmtpd-0.32/plugins/spamassassin 2006-10-24 00:15:44.000000000 -0500
@@ -38,12 +38,62 @@ The default is to never reject mail base
=item munge_subject_threshold [threshold]
Set the threshold over which we will prefix the subject with
-'***SPAM***'. A messed up subject is easier to filter on than the
-other headers for many people with not so clever mail clients. You
-might want to make another plugin that does this on a per user basis.
+'***SPAM***' (the default string). A messed up subject is easier
+to filter on than the other headers for many people with not so
+clever mail clients. You might want to make another plugin that
+does this on a per user basis.
The default is to never munge the subject based on the SpamAssassin score.
+=item munge_subject_with [string]
+
+This allows you to configure what is prepended to the subject of
+offending email enabling the receiver to appropriately handle the email
+based on its score. The default is '***SPAM***'.
+
+There are two features worth noting:
+
+=over
+
+The score of the scan can be included in this string. The arg is passed
+to standard sprintf() passing only the score. For example:
+
+=over
+
+munge_subject_with [SPAM-02.01f]
+
+=back
+
+A score of 7.2 from spamd would result in the string:
+
+=over
+
+[SPAM-7.2]
+
+=back
+
+=back
+
+Also, the string has as substitution match run against to which
+replaces all ~ (tilde) characters with spaces. This allows the
+inclusion of a space in the prepended string. For example:
+
+=over
+
+munge_subject_with [SPAM~%02.01f]
+
+=back
+
+A score of 7.2 from spand would result in the string:
+
+=over
+
+[SPAM 7.2]
+
+=back
+
+=back
+
=item spamd_socket [/path/to/socket]
Beginning with Mail::SpamAssassin 2.60, it is possible to use Unix
@@ -66,7 +116,8 @@ With both of the first options the confi
=head1 TODO
-Make the "subject munge string" configurable
+Add the ability to reject email that has overwhelmed spamd based on
+the time it's taken to scan.
=cut
@@ -83,6 +134,9 @@ sub register {
%{$self->{_args}} = @args;
+ $self->{_args}->{munge_subject_with} = '***SPAM***'
+ if (!defined($self->{_args}->{munge_subject_with}));
+
$self->register_hook("data_post", "check_spam_reject")
if $self->{_args}->{reject_threshold};
@@ -242,7 +296,9 @@ sub check_spam_munge_subject {
return DECLINED unless $score >=
$self->{_args}->{munge_subject_threshold};
my $subject = $transaction->header->get('Subject') || '';
- $transaction->header->replace('Subject', "***SPAM*** $subject");
+ my $munge = sprintf($self->{_args}->{munge_subject_with}, $score);
+ $munge =~ s/\~/ /;
+ $transaction->header->replace('Subject', "$munge $subject");
return DECLINED;
}