spamassassin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From comm...@spamassassin.apache.org
Subject [SpamAssassin Wiki] Updated: BayesFeedbackViaForwarding
Date Wed, 16 Mar 2005 20:49:31 GMT
   Date: 2005-03-16T12:49:31
   Editor: ChrisGamache
   Wiki: SpamAssassin Wiki
   Page: BayesFeedbackViaForwarding
   URL: http://wiki.apache.org/spamassassin/BayesFeedbackViaForwarding

   my $0.02 ... I thought the mods might come in handy ...

Change Log:

------------------------------------------------------------------------------
@@ -212,5 +212,54 @@
 
 1;
 }}}
+
+Alternately, you can use this wrapper for sa-learn and call it from a .qmail file for on-the-fly
split-and-add-via-forward.
+
+/usr/bin/learn_spam:
+{{{
+#!/usr/bin/perl
+#
+#      run sa-learn on STDIN ... easy to use with .qmail files:
+#
+#  .qmail-spamtrap:  
+#      | bayes_fixup.pl | learn_spam --spam --username=alias | cat - > /dev/null
+#  .qmail-qqqhamreport:
+#      | bayes_fixup.pl | learn_spam --ham --username=alias | cat - > /dev/null
+#
+#  4/16/2005 -- cgg007 at yahoo.com
+#
+
+use strict;
+
+sub learn {
+  my $message = shift;
+  my $pipe = shift;
+  open LEARN, $pipe;
+  print LEARN $message;
+  close LEARN;
+}
+
+my $learn_cmd =  "| bayes_fixup.pl | sa-learn " . join(" ",@ARGV);
+my $count = 0;
+my $message = '';
+
+while (<STDIN>) {
+
+  /^From/ and do {
+    if ($count) {
+      learn($message,$learn_cmd) if $count;
+      $message = '';
+    }
+    $count++;
+  };
+
+  $message .= $_;
+
+}
+
+learn($message,$learn_cmd);
+
+}}}
+
 ----
 CategoryBayes

Mime
View raw message