test
[hcoop/zz_old/ikiwiki] / FeedingSpamAssassin.mdwn
1
2 This page contains example scripts for automating the process of
3 giving SpamAssassin feedback.
4
5 = Warning =
6
7 Your mileage may vary. Feel free to fix bugs. Test these scripts
8 before making use of them. Make sure you know what you're doing.
9
10 = Scripts =
11
12 '''feed-site-spam''': Feed uncaught spam messages to SpamAssassin.
13
14 '''NOTE''': It is assumed that you empty your Spam folder after
15 running this script. Otherwise you'll feed some of the same messages
16 to SpamAssassin every time you run the script.
17
18 {{{
19 #!/bin/bash
20
21 # Location of your spam directory
22 SPAMDIR=~/Maildir/.Spam.Definitely/cur
23
24 # Destination directory for spam messages
25 SHAREDDIR=/etc/spamassassin/Maildir/.SiteSpam/cur
26
27 # Copy files were not marked as spam to the site folder
28 for i in $(find $SPAMDIR -type f -print0 | xargs -0 grep -l "^X-Spam-Status: N");
29 do
30 cp $i $SHAREDDIR
31 done
32 }}}
33
34
35 '''feed-site-ham'''
36
37 {{{
38 #!/bin/bash
39
40 # Prefix for folder locations
41 MAILPRE=~/Maildir/.
42
43 # IMAP directories that contain definite non-spam (ham)
44 HAMDIRS="Bugs Family Friends Fun Gnu Info Lists Plug School Work"
45
46 # Destination directory for ham messages
47 SHAREDDIR=/etc/spamassassin/Maildir/.SiteHam/cur
48
49 # Copy files that were erroneously marked as spam to the site folder.
50 # Note: This includes email with a spam level of 3 or higher,
51 # 30 days old or less.
52 for i in $HAMDIRS; do
53 echo Learning ham in $i:
54 for i in $(find $MAILPRE$i/cur -type f -ctime 30 -print0 | xargs -0 grep -l "^X-Spam-Level:.*\*\*\*");
55 do
56 cp $i $SHAREDDIR
57 done
58 done
59 }}}