3 # these are for non-spamc setups
4 SPAM_REPORT="spamassassin --report"
5 HAM_REPORT="spamassassin --revoke"
6 SPAM_CHECK="spamassassin -e"
9 SPAM_REPORT="spamc --learntype=spam"
10 HAM_REPORT="spamc --learntype=ham"
13 if [ "$(basename $0)" = "learn_from_spam" ]; then
15 if ! formail -c < "$file"|grep -q '^List-Id'; then
16 $SPAM_REPORT < "$file" >/dev/null 2>&1;
18 formail -c < "$file" | grep -e '^From ' -e 'From: ' | spamassassin --add-to-blacklist >/dev/null 2>&1;
19 formail -c < "$file" | grep -e '^From ' -e 'From: ' | spamassassin --remove-from-whitelist >/dev/null 2>&1;
20 # check to see if it's still spam
21 if ! $SPAM_CHECK < "$file" >/dev/null 2>&1; then
22 # this message is still not spam; may need custom rules
23 spamc < "$file" > ~/Maildir/spam/needs_rules/cur/"$(basename "$file")" 2>/dev/null;
26 elif [ "$(basename $0)" = "learn_from_ham" ]; then
28 $HAM_REPORT < "$file" >/dev/null 2>&1;
29 formail -c < "$file" |grep -e '^From ' -e 'From: ' -e 'To: ' -e 'Cc: '|spamassassin --add-to-whitelist >/dev/null 2>&1;
30 if $SPAM_CHECK < "$file" >/dev/null 2>&1; then
31 mkdir -p ~/Maildir/spam/needs_ham_rules/cur;
32 spamc < "$file" > ~/Maildir/spam/needs_ham_rules/cur/"$(basename "$file")" 2>/dev/null;
36 "Called in a way this script cannot recognize";