#!/bin/bash # these are for non-spamc setups SPAM_REPORT="spamassassin --report" HAM_REPORT="spamassassin --revoke" SPAM_CHECK="spamassassin -e" # these are for spamc SPAM_REPORT="spamc --learntype=spam" HAM_REPORT="spamc --learntype=ham" SPAM_CHECK="spamc -c" if [ "$(basename $0)" = "learn_from_spam" ]; then for file in "$@"; do $SPAM_REPORT < "$file" >/dev/null; grep -e '^From ' -e 'From: ' "$file" | spamassassin -R >/dev/null; # check to see if it's still spam if ! spamc -c < "$file"; then # this message is still not spam; may need custom rules cp "$file" ~/Maildir/spam/needs_rules/cur/; fi; done; elif [ "$(basename $0)" = "learn_from_ham" ]; then for file in "$@"; do $HAM_REPORT < "$file" >/dev/null; grep -e '^From ' -e 'From: ' -e 'To: ' -e 'Cc: ' "$file"|spamassassin -W>/dev/null; done; else "Called in a way this script cannot recognize"; fi;