From bf450cece3c634d0c6b90e35b31221acedb1e60b Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Thu, 13 Feb 2014 16:13:11 -0800 Subject: [PATCH] update learn from spam to archive spam which still doesn't scan as spam --- learn_from_spam | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/learn_from_spam b/learn_from_spam index 0072598..96f9bd9 100755 --- a/learn_from_spam +++ b/learn_from_spam @@ -1,13 +1,28 @@ #!/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 - spamassassin -r < "$file" >/dev/null; + $SPAM_REPORT < "$file" >/dev/null; grep -e '^From ' -e 'From: ' "$file" | spamassassin -R >/dev/null; + # check to see if it's still spam + if ! spam -c < "$file"; then + # this message is still not spam; may need custom rules + cp "$file" ~/Mail/spam/needs_rules/cur/; + fi; done; elif [ "$(basename $0)" = "learn_from_ham" ]; then for file in "$@"; do - spamassassin -k < "$file" >/dev/null; + $HAM_REPORT < "$file" >/dev/null; grep -e '^From ' -e 'From: ' -e 'To: ' -e 'Cc: ' "$file"|spamassassin -W>/dev/null; done; else -- 2.39.5