2 # Copyright (C) 2008-2013, Eric Wong <e@80x24.org>
3 # License: GPLv3 or later <http://www.gnu.org/licenses/gpl-3.0.txt>
4 # Usage: report-spam /path/to/message/in/maildir
5 # This is intended to be used with incron or similar systems.
6 # my incrontab(5) looks like this:
7 # /path/to/.maildir/cur IN_MOVED_TO /path/to/report-spam $@/$#
8 # /path/to/.maildir/.INBOX.good/cur IN_MOVED_TO /path/to/report-spam $@/$#
9 # /path/to/.maildir/.INBOX.spam/cur IN_MOVED_TO /path/to/report-spam $@/$#
11 # gigantic emails tend not to be spam (but they suck anyways...)
12 bytes=$(stat -c %s $1)
13 if test $bytes -gt 512000
18 # Only tested with the /usr/sbin/sendmail which ships with postfix
19 # *** Why not call spamc directly in this script? ***
20 # I route this through my MTA so it gets queued properly.
21 # incrond has no concurrency limits and will fork a new process on
22 # every single event, which sucks with rename storms when a client
23 # commits folder changes. The sendmail executable exits quickly and
24 # queues up the message for training. This shoudl also ensure fairness
25 # to newly arriving mail. Instead of installing/configuring
26 # another queueing system, I reuse the queue in the MTA.
27 # See scripts/dc-dlvr for corresponding trainspam/trainham handlers.
29 *[/.]spam/cur/*) # non-new messages in spam get trained
30 exec /usr/sbin/sendmail -oem -oi $USER+trainspam < $1
32 *:2,*S*) # otherwise, seen messages only
34 *:2,*T*) exit 0 ;; # ignore trashed messages
36 exec /usr/sbin/sendmail -oem -oi $USER+trainham < $1