Start > Linux Tips & Trics > Mailsplitter


28 oktober 2006

We use Spamassassin as anti spam tool with Bayes learning. If I want to feed spam massages to the sa-learn tool, I have to get individual messages from my Thunderbird Mailfolder which stores all mails together in a text file.

First I move alle spam massages to the Thunderbird Junk mail. Thunderbird has a build in learning tool to fight spam, so most spam messages are moved to the junk folder automagically. Make sure there are no messages in this folder that are already marked as spam by Spamassassin!
Split a Thundebird mailfolder into individual Mails:

  1. targetfolder=/tmp/spam
  2. if [ ! -d "$targetfolder" ]; then
  3. echo "targetfolder $targetfolder does not exists";
  4. exit 1;
  5. fi
  6. m=0
  7. find ~/.mozilla-thunderbird -type f -name Junk|while read junkfile; do
  8. i=0
  9. for line in `grep -n "From – " "$junkfile" | cut -d: -f1`; do
  10. if [ $i -gt 0 ]; then
  11. head "$junkfile" -n $(echo $line-1|bc) | tail -n $(echo $line-$cl|bc) > $targetfolder/msg$(printf "%09d" $m).eml
  12. fi
  13. let i=$i+1
  14. let m=$m+1
  15. cl=$line
  16. done
  17. done
Categorie├źn:Linux Tips & Trics Tags:
Geen reacties mogelijk.