Re: New mailman version



On Sat, Jun 07, 2008 at 01:33:39PM +0200, Olav Vitters wrote:
> Note: I plan to integrate the discarded / accepted messages with
> Spamassassin (bayes stuff).

This has been done. See the attachments for the cron script + mailman
patch. The ~/.procmailrc is trivial, not attaching that.

-- 
Regards,
Olav
diff -ru q/mailman-2.1.10/Mailman/Cgi/admindb.py mailman-2.1.10/Mailman/Cgi/admindb.py
--- q/mailman-2.1.10/Mailman/Cgi/admindb.py	2008-04-21 20:28:22.000000000 +0200
+++ mailman-2.1.10/Mailman/Cgi/admindb.py	2008-06-07 22:32:45.000000000 +0200
@@ -197,6 +197,11 @@
                 ' ' +
                 _('Discard all messages marked <em>Defer</em>')
                 ))
+            form.AddItem(Center(
+                CheckBox('trainbayesp', 0).Format() +
+                '&nbsp;' +
+                _('Use messages marked as <em>Discard</em> and <em>Accept</em> to train the Bayesian classifier')
+                ))
         # Add a link back to the overview, if we're not viewing the overview!
         adminurl = mlist.GetScriptURL('admin', absolute=1)
         d = {'listname'  : mlist.real_name,
@@ -245,6 +250,11 @@
                     '&nbsp;' +
                     _('Discard all messages marked <em>Defer</em>')
                     ))
+                form.AddItem(Center(
+                    CheckBox('trainbayesp', 0).Format() +
+                    '&nbsp;' +
+                    _('Use messages marked as <em>Defer</em> and <em>Accept</em> to train the Bayesian classifier')
+                    ))
             form.AddItem(Center(SubmitButton('submit', _('Submit All Data'))))
         doc.AddItem(mlist.GetMailmanFooter())
         print doc.Format()
@@ -695,6 +705,10 @@
         discardalldefersp = cgidata.getvalue('discardalldefersp', 0)
     except ValueError:
         discardalldefersp = 0
+    try:
+        trainbayesp = cgidata.getvalue('trainbayesp', 0)
+    except ValueError:
+        trainbayesp = 0
     for sender in senderactions.keys():
         actions = senderactions[sender]
         # Handle what to do about all this sender's held messages
@@ -709,6 +723,13 @@
             preserve = actions.get('senderpreserve', 0)
             forward = actions.get('senderforward', 0)
             forwardaddr = actions.get('senderforwardto', '')
+            if trainbayesp and not forward:
+                if action == mm_cfg.DISCARD:
+                    forward = 1
+                    forwardaddr = 'XXX gnome.org'
+                elif action == mm_cfg.APPROVE:
+                    forward = 1
+                    forwardaddr = 'XXX gnome.org'
             comment = _('No reason given')
             bysender = helds_by_sender(mlist)
             for id in bysender.get(sender, []):

Attachment: bayes.png
Description: PNG image

#!/bin/sh
#
# Mailman has been patched to forward messages marked as Dischard + Accept to
# the amavis user.
#
# It uses plussed addresses for that. 
#
# There is a procmail rule which sends the body of that email to two mailboxes.
# The Mailman email has content type message/rfc822. Meaning: the original
# message is preserved by only sending the body to the mbox.
#
# This scripts runs in cron and uses the mbox to train the bayes classifier.
#

cd $HOME

type="spam"
if [ -e bayes-$type/new ]; then
	rm -rf bayes-$type/train
	mv -f bayes-$type/new bayes-$type/train
	sa-learn --$type bayes-$type/train
fi

type="ham"
if [ -e bayes-$type/new ]; then
	rm -rf bayes-$type/train
	mv -f bayes-$type/new bayes-$type/train
	sa-learn --$type bayes-$type/train
fi



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]