From 82c6f93bfcf00f4f65b2cf89aefaee6d8155e0e2 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Fri, 17 Jan 2014 09:12:48 -0800 Subject: [PATCH] Do spam check after all other checks, as it is expensive http://virtualmin.com/node/32098 --- sendmail/autoreply.pl | 52 +++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/sendmail/autoreply.pl b/sendmail/autoreply.pl index 5097b8652..3198382cd 100755 --- a/sendmail/autoreply.pl +++ b/sendmail/autoreply.pl @@ -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() { - 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() { + 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;