rev 1393 - trunk/Siesta-Plugin-SpamAssassin/lib/Siesta/Plugin

[prev] [thread] [next] [lurker] [Date index for 2003/09/02]

From: simon
Subject: rev 1393 - trunk/Siesta-Plugin-SpamAssassin/lib/Siesta/Plugin
Date: 18:01 on 02 Sep 2003
Author: simon
Date: 2003-09-02 18:01:23 +0100 (Tue, 02 Sep 2003)
New Revision: 1393

Modified:
   trunk/Siesta-Plugin-SpamAssassin/lib/Siesta/Plugin/SpamAssassin.pm
Log:
Start reworking 


Modified: trunk/Siesta-Plugin-SpamAssassin/lib/Siesta/Plugin/SpamAssassin.pm
===================================================================
--- trunk/Siesta-Plugin-SpamAssassin/lib/Siesta/Plugin/SpamAssassin.pm	2003-09-02 15:33:22 UTC (rev 1392)
+++ trunk/Siesta-Plugin-SpamAssassin/lib/Siesta/Plugin/SpamAssassin.pm	2003-09-02 17:01:23 UTC (rev 1393)
@@ -4,7 +4,7 @@
 use base 'Siesta::Plugin';
 
 use vars qw($VERSION);
-$VERSION = '0.01';
+$VERSION = '0.2';
 
 sub description {
     "Check to see if the mail is spam using the heuristics ".
@@ -13,21 +13,66 @@
 
 # specific includes
 use Mail::SpamAssassin;
-use Mail::Audit;
 
 sub process {
     my $self = shift;
     my $mail = shift;
 
-    my $ma = Mail::Audit->new( data => [ split /\n/, $mail->as_string ] );
+	# sigh. This feels dirty
+	my $mi       = Mail::Internet->new([split /\n/, $mail->as_string]);
     my $spamtest = Mail::SpamAssassin->new();
-    my $status   = $spamtest->check($ma);
+    my $status   = $spamtest->check($mi);
 
-    # Naughty person.
-    return 1 if $status->is_spam();
 
-    # it all seems to be ok, go about your business
-    return;
+	return 0 unless $status->is_spam;
+	# They're a naughty, naughty person.
+
+
+
+	# the options are ...
+
+	# 1) defer the message only if they're a subscriber 
+	if (($self->pref('action')==1 && $list->is_member( $mail->from )) || 
+	# or 
+	# 2) defer it anyway
+	     $self->pref('action')==2) {
+
+		my $id = $mail->defer(
+            why => "this looks like spam",
+            who => $list->owner);
+
+		$mail->reply( to      => $list->owner->email,
+                      from    => $list->address('resume'),
+                      subject => "deferred message - we think this is spam",
+                      body    => Siesta->bake('spam_mail',
+                                              list     => $list,
+                                              mail     => $mail,
+                                              deferred => $id),
+                     );
+
+	# 3) let them through anyway, but as long as it's a member
+	} elsif ($self->pref('action') == 3) {
+		return 0  $list->is_member( $mail->from );
+	} else {
+		# drop them silently
+		return 1; 
+	}
+
+	# Reject. we should never get to this though.
+    return 1;
 }
 
+sub options {
+    +{
+      'action'
+      => {
+          description => "what should we do? 0 = drop it silently (default), 1 = defer the message only if they're a subscriber, 2 = always defer, 3 = let them through anyway if they're a subscriber
+          type        => "number",
+          default     => 0,
+         },
+     };
+}
+
+
+
 1;

Generated at 13:57 on 01 Jul 2004 by mariachi 0.52