View Single Post
Old 5 Oct 2019, 06:24 AM   #30
xyzzy
Essential Contributor
 
Join Date: May 2018
Posts: 474
For those of you who lost the Add Spam Spam Protection setting (and me who got it back but in anticipation of probably losing it again someday) where emails classed as spam have their subject line prefixed with "{SPAM XX.X}" and can't convenience FM to re-enable it, I came up with a way to simulate with some sieve code.

There's an unrelated thread where a poster named verbovet posted a snippet of sieve code (post 14 in that thread) that used deleteheader/addheader on the "From" header. I never even thought about using them before on a header normally displayed in the email. So that gave me the idea of doing the same thing with the Subject header to simulate the Add Spam setting for those that lost it and want it back.

Code:
if allof(false, # change to true to enable should Add Spam be removed
         header :value "ge" :comparator "i;ascii-numeric" "X-Spam-score" "${SPAM_THRESHOLD}",
         header :matches "Subject" "*") {
  set "subject" "${1}";
  if header :matches "X-Spam-score" "*" {
    set "spam_score" "${1}";
    if header :value "lt" :comparator "i;ascii-numeric" "X-Spam-score" "10" {
      set "spam_score" "0${1}"; # add leading 0 for spam scores < 10
    }
    deleteheader "Subject";
    addheader "Subject" "{SPAM ${spam_score}} ${subject}";
  }
}
A convenient place for this code is near the beginning, i.e., before section 1. I have other stuff in there already including setting of the variable SPAM_THRESHOLD used in the above code, for example,

set "SPAM_THRESHOLD" "6.2";

Thanks verbovet for giving me the idea.

Last edited by xyzzy : 5 Oct 2019 at 07:06 AM.
xyzzy is offline   Reply With Quote