Do spam check after all other checks, as it is expensive http://virtualmin.com/node/32098

This commit is contained in:
Jamie Cameron
2014-01-17 09:12:48 -08:00
parent 15ec334948
commit 82c6f93bfc

View File

@@ -77,32 +77,6 @@ if ($header{'from'} =~ /postmaster|mailer-daemon/i ||
exit 0;
}
# if spamassassin is installed, feed the email to it
$spam = &has_command("spamassassin");
if ($spam) {
$temp = "/tmp/autoreply.spam.$$";
unlink($temp);
open(SPAM, "| $spam >$temp 2>/dev/null");
print SPAM $headers;
print SPAM $body;
close(SPAM);
$isspam = undef;
open(SPAMOUT, $temp);
while(<SPAMOUT>) {
if (/^X-Spam-Status:\s+Yes/i) {
$isspam = 1;
last;
}
last if (!/\S/);
}
close(SPAMOUT);
unlink($temp);
if ($isspam) {
print STDERR "Not autoreplying to spam\n";
exit 0;
}
}
# work out the correct to address
@to = ( &split_addresses($header{'to'}),
&split_addresses($header{'cc'}),
@@ -213,6 +187,32 @@ foreach $re (@no_regexp) {
}
}
# if spamassassin is installed, feed the email to it
$spam = &has_command("spamassassin");
if ($spam) {
$temp = "/tmp/autoreply.spam.$$";
unlink($temp);
open(SPAM, "| $spam >$temp 2>/dev/null");
print SPAM $headers;
print SPAM $body;
close(SPAM);
$isspam = undef;
open(SPAMOUT, $temp);
while(<SPAMOUT>) {
if (/^X-Spam-Status:\s+Yes/i) {
$isspam = 1;
last;
}
last if (!/\S/);
}
close(SPAMOUT);
unlink($temp);
if ($isspam) {
print STDERR "Not autoreplying to spam\n";
exit 0;
}
}
# Read attached files
foreach $f (@files) {
local $/ = undef;