about summary refs log tree commit homepage
path: root/scripts/report-spam
blob: a0c6da368bdd9b25f59a2e3c8c50eecc4a030bc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh
# Copyright (C) 2008-2013, Eric Wong <e@80x24.org>
# License: GPLv3 or later <http://www.gnu.org/licenses/gpl-3.0.txt>
# Usage: report-spam /path/to/message/in/maildir
# my incrontab(5) looks like this:
#  /path/to/.maildir/cur IN_MOVED_TO /path/to/report-spam $@/$#
#  /path/to/.maildir/.INBOX.good/cur IN_MOVED_TO /path/to/report-spam $@/$#
#  /path/to/.maildir/.INBOX.spam/cur IN_MOVED_TO /path/to/report-spam $@/$#

# gigantic emails tend not to be spam (but they suck anyways...)
bytes=$(stat -c %s $1)
if test $bytes -gt 512000
then
	exit
fi

# only tested with the /usr/sbin/sendmail which ships with postfix
case $1 in
*[/.]spam/cur/*) # non-new messages in spam get trained
	exec /usr/sbin/sendmail -oem -oi $USER+trainspam < $1
	;;
*:2,*S*) # otherwise, seen messages only
	case $1 in
	*:2,*T*) exit 0 ;; # ignore trashed messages
	esac
	exec /usr/sbin/sendmail -oem -oi $USER+trainham < $1
	;;
esac