]> git.donarmstrong.com Git - bin.git/commitdiff
use formail -c to handle from and to addresses
authorDon Armstrong <don@donarmstrong.com>
Fri, 14 Feb 2014 21:57:20 +0000 (13:57 -0800)
committerDon Armstrong <don@donarmstrong.com>
Fri, 14 Feb 2014 21:57:20 +0000 (13:57 -0800)
redo report for spam messages before sticking into the needs rules directory

learn_from_spam

index 88545f85dbb848ff9d714fa6b94f8fe29add8c1d..4cacf66433e89567c2cae78d2eefc5be537fb572 100755 (executable)
@@ -13,17 +13,17 @@ 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;
+        formail -c < "$file" | grep -e '^From ' -e 'From: ' | spamassassin -R >/dev/null;
         # check to see if it's still spam
-        if ! spamc -c < "$file"; then
+        if ! spamc -c < "$file" >/dev/null; then
             # this message is still not spam; may need custom rules
-            cp "$file" ~/Maildir/spam/needs_rules/cur/;
+            spamc "$file" > ~/Maildir/spam/needs_rules/cur/"$(basename "$file")";
         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;
+        formail -c < "$file" |grep -e '^From ' -e 'From: ' -e 'To: ' -e 'Cc: '|spamassassin -W>/dev/null;
     done;
 else
     "Called in a way this script cannot recognize";