X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=learn_from_spam;h=306b227c4e13975c49efc4bde800dda786910f22;hb=06e21be610f2c792ec732bebacd0b35856200934;hp=96f9bd97400a81e2934f21e74019815ab600a8e2;hpb=bf450cece3c634d0c6b90e35b31221acedb1e60b;p=bin.git diff --git a/learn_from_spam b/learn_from_spam index 96f9bd9..306b227 100755 --- a/learn_from_spam +++ b/learn_from_spam @@ -12,18 +12,25 @@ 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; + if ! formail -c < "$file"|grep -q '^List-Id'; then + $SPAM_REPORT < "$file" >/dev/null 2>&1; + fi; + formail -c < "$file" | grep -e '^From ' -e 'From: ' | spamassassin --add-to-blacklist >/dev/null 2>&1; + formail -c < "$file" | grep -e '^From ' -e 'From: ' | spamassassin --remove-from-whitelist >/dev/null 2>&1; # check to see if it's still spam - if ! spam -c < "$file"; then + if ! $SPAM_CHECK < "$file" >/dev/null 2>&1; then # this message is still not spam; may need custom rules - cp "$file" ~/Mail/spam/needs_rules/cur/; + spamc < "$file" > ~/Maildir/spam/needs_rules/cur/"$(basename "$file")" 2>/dev/null; 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; + $HAM_REPORT < "$file" >/dev/null 2>&1; + formail -c < "$file" |grep -e '^From ' -e 'From: ' -e 'To: ' -e 'Cc: '|spamassassin --add-to-whitelist >/dev/null 2>&1; + if $SPAM_CHECK < "$file" >/dev/null 2>&1; then + mkdir -p ~/Maildir/spam/needs_ham_rules/cur; + spamc < "$file" > ~/Maildir/spam/needs_ham_rules/cur/"$(basename "$file")" 2>/dev/null; + fi; done; else "Called in a way this script cannot recognize";