1

I was looking whole morning and found nothing.

I have a debian box running dovecot IMAP. I want to train the spamassassin with the users spam folders.

is there something similar like sa-learn-cyrus for dovecot?

3
  • 1
    The top result from Google search is AntiSpam plugin for dovecot. Have you try that?
    – masegaloeh
    Jul 2, 2014 at 14:17
  • 1
    An important question: what format are your mailboxes in? If in mbox format, I dunno. If in Maildir format, I may have a solution. Jul 2, 2014 at 19:35
  • @AveryPayne maildir format
    – Max Muster
    Jul 2, 2014 at 22:03

2 Answers 2

3

SpamAssassin comes with sa-learn out of the box (not to be confused with the sa-learn-cyrus you mentioned). It comes with two learning modes, ham and spam. It would take a very, very simple script to walk through each user's mailbox, doing a "ham" pass at first, and a second walk-through for "spam". Something (roughly) like:

#!/bin/bash

# change these to reflect the folder layout used on your server
BASEDIR=/home
UINBOX=Maildir/Inbox
USPAMBOX=Maildir/Spam

# do some housekeeping...
sa-learn --force-expire

# enumerate each user and process ham/spam
for USRNAME in `ls -l /home`
do
  for MAILSTATE in new cur
  do
    sa-learn --ham $BASEDIR/$USRNAME/$UINBOX/$MAILSTATE/*
    sa-learn --spam $BASEDIR/$USRNAME/$USPAMBOX/$MAILSTATE/*
  done
done

Place in in a file, let's call it sa-trainer.sh. I included the already-read mail as part of the process, just in case something is read (intentionally or accidentially). It won't matter much to the process, as the duplicates will be detected and effectively ignored.

3
  • 2
    Just to be complete: if you want to use sa-learn together with mbox format files, there's the salearn --mbox parameter. Jul 3, 2014 at 5:21
  • Does it also read all the already with "*** SPAM ***" marked Emails or does it ignore them, and read only the emails that are in /home/user/Inbox/Spam/{cur|new} that are not taged spam??
    – Max Muster
    Jul 3, 2014 at 6:02
  • It doesn't care as much about a spam-tag in the subject line or header, although I'm sure it will factor into the bayesian part of SA. The documentation states that if it has seen a message before, it effectively ignores it. I don't know the exact criteria that it uses to determine this, although I could hazard a guess and say that it looks at the unique message ID. Jul 3, 2014 at 18:50
2

I wrote my own script using doveadm search to read training mails from certain IMAP folders in my own account.

The usual disclaimers apply, it is not pretty but works for me. You will also have to remove the crm114 mailtrainer.crm call at the end.

Edit: I realized my script also uses crm114 feature (a cache dir of all processed messages in crm114/reaver_cache/texts), so it will not work for normal installations.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .