]> Sergey Matveev's repositories - public-inbox.git/blob - scripts/report-spam
initial commit
[public-inbox.git] / scripts / report-spam
1 #!/bin/sh
2 # Copyright (C) 2008-2013, Eric Wong <e@80x24.org>
3 # License: GPLv3 or later
4 # Usage: report-spam /path/to/message/in/maildir
5 # my incrontab(5) looks like this:
6 #  /path/to/.maildir/cur IN_MOVED_TO /path/to/report-spam $@/$#
7 #  /path/to/.maildir/.INBOX.good/cur IN_MOVED_TO /path/to/report-spam $@/$#
8 #  /path/to/.maildir/.INBOX.spam/cur IN_MOVED_TO /path/to/report-spam $@/$#
9
10 # gigantic emails tend not to be spam (but they suck anyways...)
11 bytes=$(stat -c %s $1)
12 if test $bytes -gt 512000
13 then
14         exit
15 fi
16
17 # only tested with the /usr/sbin/sendmail which ships with postfix
18 case $1 in
19 *[/.]spam/cur/*) # non-new messages in spam get trained
20         exec /usr/sbin/sendmail -oem -oi $USER+trainspam < $1
21         ;;
22 *:2,*S*) # otherwise, seen messages only
23         case $1 in
24         *:2,*T*) exit 0 ;; # ignore trashed messages
25         esac
26         exec /usr/sbin/sendmail -oem -oi $USER+trainham < $1
27         ;;
28 esac