You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by co...@spamassassin.apache.org on 2005/03/16 21:49:31 UTC

[SpamAssassin Wiki] Updated: BayesFeedbackViaForwarding

   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