1

I'm running fetchmail on a AntiSpam server to get messages on user's junk folder to feed SpamAssassin bayesian filtering. It's been running nicely with the -m option in fetchmail to deliver the messages to SpamAssassin sa-learn tool.

But I would like to start testing Bogofilter and feed the Bogofilter database accordingly. But to do this fetchmail should deliver the messages to SpamAssassin and Bogofilter, and using the -m was a no go.

There's a way to achive this with fetchmail? I've considered some extra MDA's like procmail or maildrop, but I'm not sure if it's really necessary or if it will do the work.

EDIT: My actual fetchmail command to fetch messages from the mail server:

echo "poll $mailserver proto IMAP user $domain\\$user\\$mailbox pass $passwd ssl" \
| fetchmail -a -n -p IMAP --folder "$junkfolder" -f - -m '/usr/local/bin/sa-learn \
-C /usr/mailcleaner/etc/mailscanner/spam.assassin.prefs.conf --spam'

EDIT: I GOT IT! Answering my own question...

Vinícius Ferrão
  • 5,400
  • 10
  • 52
  • 91

1 Answers1

1

This is easy enough to do if you use Procmail as the LDA. Here is a Procmail recipe to pass the message to two different scripts, then deliver it to SPAM. (Deliver to /dev/null instead if you don't want to keep it; or equivalently, remove the c flag from the last recipe.)

# I doubt this is necessary, but since you were using an explicit path name...
PATH=/usr/local/bin:$PATH

:0c
| sa-learn -C /usr/mailcleaner/etc/mailscanner/spam.assassin.prefs.conf --spam

:0c
| bogofilter

:0
SPAM/

It's not hard to write a shell script which performs the same actions, but Procmail does a bunch of things to make sure email is not lost or delivered insecurely, so it's nice as a wrapper.

tripleee
  • 1,324
  • 3
  • 14
  • 24
  • Obviously, you could do the same thing with Maildrop as well. I'm not familiar enough with Maildrop to actually post a solution. – tripleee Jul 11 '14 at 09:57