0

I'm using SpamAssassin to analyse existing emails, so I have an archive folder on my file system that contains a large amount of (already read, old) emails.

Among those emails there are quite a lot of spam emails that have not been analysed by SpamAssassin yet, because I only recently installed SpamAssassin on my system.

Is it possible to let SpamAssassin analyse the emails of that folder? I would like to filter out all the spam emails automatically.

Jay Kominek
  • 8,674
  • 1
  • 34
  • 51
LaDude
  • 1,383
  • 1
  • 11
  • 27

1 Answers1

0

This is pretty easy with a shell script. This can be run within a Maildir folder on a Linux box:

#!/bin/bash
for mailfile in *; do
  spamc -c < $mailfile
  if [[ $? == 1 ]]; then # it's spam
    mv $mailfile ~/junk/
  fi
done

Change ~/junk to the location of a junk folder and let'r rip. It'll take a while, but it should process the entire directory. You may want to change the * to better match the files in your Maildir folder.

Allen Luce
  • 7,859
  • 3
  • 40
  • 53