<br><div class="gmail_quote"><br>Can anyone explain me where I should place the following code....<br><br>thanks,<br><br><pre>Here is a patch to implement a spam filter using pattern matching on a<br>configurable header field, instead of running spamassassin. <br>
<br><br><br>--- lib/RT/Interface/Email/Filter/SpamHeader.pm 2004-02-18 16:26:44.000000000 +0100<br>+++ lib/RT/Interface/Email/Filter/SpamHeader.pm 2004-08-31 08:28:53.000000000 +0200<br>@@ -0,0 +1,101 @@<br>+# BEGIN LICENSE BLOCK<br>
+# <br>+# Copyright (c) 2004 Petter Reinholdtsen <<a href="http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel" target="_blank">pere at hungry.com</a>><br>+# <br>+# This work is made available to you under the terms of Version 2 of<br>
+# the GNU General Public License. A copy of that license should have<br>+# been provided with this software, but in any event can be snarfed<br>+# from <a href="http://www.gnu.org" target="_blank">www.gnu.org</a>.<br>+# <br>
+# This work is distributed in the hope that it will be useful, but<br>
+# WITHOUT ANY WARRANTY; without even the implied warranty of<br>+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU<br>+# General Public License for more details.<br>+# <br>+# Unless otherwise specified, all modifications, corrections or<br>
+# extensions to this work which alter its source code become the<br>+# property of Best Practical Solutions, LLC when submitted for<br>+# inclusion in the work.<br>+# <br>+# <br>+# END LICENSE BLOCK<br>+package RT::Interface::Email::Filter::SpamHeader;<br>
+<br>+use RT::EmailParser;<br>+<br>+sub GetCurrentUser {<br>+ my %args = ( Message => undef,<br>+ CurrentUser => undef,<br>+ AuthLevel => undef,<br>+ Queue => undef,<br>+ @_ );<br>+<br>
+ # Check configuration.<br>
+ unless ($RT::SpamHeader) {<br>+ $RT::Logger->error("SpamHeader: Content of \$RT::SpamHeader is empty.");<br>+ return ($args{'CurrentUser'}, $args{'AuthLevel'});<br>+ }<br>+ unless ($RT::SpamLowMatch) {<br>
+ $RT::Logger->error("SpamHeader: Content of \$RT::SpamLowMatch is empty.");<br>+ return ($args{'CurrentUser'}, $args{'AuthLevel'});<br>+ }<br>+ my $Message = $args{'Message'};<br>
+ unless ($Message) {<br>+ $RT::Logger->error("SpamHeader: \$Message is empty.");<br>+ return ($args{'CurrentUser'}, $args{'AuthLevel'});<br>+ }<br>+ <br>+ my $head = $Message->head;<br>
+ my $spamtag = $head->get($RT::SpamHeader);<br>+<br>+ if (defined $RT::SpamHighMatch && $spamtag =~ m/$RT::SpamHighMatch/) {<br>+ if ($RT::SpamHighQueue) {<br>+ # Move to spam queue<br>+ $args{'Queue'}->Load( $RT::SpamHighQueue );<br>
+ } else {<br>+ # tell Gateway() to drop the mail<br>+ $RT::Logger->info("SpamHeader: Dropping spam message!");<br>+ return ($args{CurrentUser}, -1);<br>+ }<br>+ }<br>+<br>+ if ($spamtag =~ m/$RT::SpamLowMatch/) {<br>
+ if ($RT::SpamLowQueue) {<br>+ # Move to spam queue<br>+ $args{'Queue'}->Load( $RT::SpamLowQueue );<br>+ } else {<br>+ # tell Gateway() to drop the mail<br>+ $RT::Logger->info("SpamHeader: Dropping spam message!");<br>
+ return ($args{CurrentUser}, -1);<br>+ }<br>+ }<br>+<br>+ $RT::Logger->debug("SpamHeader: Accepting non-spam message.");<br>+ return ($args{'CurrentUser'}, $args{'AuthLevel'});<br>
+}<br>+<br>+=head1 NAME<br>+<br>+RT::Interface::Email::Filter::SpamHeader - Filter spam based on header tags<br>+<br>+=head1 SYNOPSIS<br>+<br>+ Set($SpamHeader, "X-UiO-Spam-Score"); # Required<br>+ Set($SpamLowMatch, "ss+"); # Required<br>
+ Set($SpamLowQueue, "spam"); # Optional<br>+ Set($SpamHighMatch, "ssssss+"); # Optional<br>+ Set($SpamHighQueue, undef); # Optional<br>+ @RT::MailPlugins = ("Filter::SpamHeader", ...); # Required<br>
+<br>+=head1 DESCRIPTION<br>+<br>+This plugin checks to see if an incoming mail is spam by looking at<br>+the header field given in $SpamHeader, matching it using the regex in<br>+$SpamLowMatch and $SpamHighMatch. If the regex matches, it is<br>
+considered spam and dropped on the floor or moved to a spam queue if<br>+the corresponding queue variable is set. Otherwise, it is handled as<br>+normal.<br>+<br>+=cut<br>+<br>+1;</pre><br>
<br></div><br>