View Single Post
Old 9 Sep 2019, 04:47 AM   #16
JamesHenderson
Cornerstone of the Community
 
Join Date: Jan 2003
Location: Oxfordshire, UK
Posts: 603
Quote:
Originally Posted by xyzzy View Post
When I refer to a sieve section number I am referring to the numbered comments in the portions of the sieve script you cannot edit. For example section 3 starts with the comment,

### 3. Sieve generated for spam protection

Or to use your examples section 5 is Vacation and section 6 calendar. It's thus easier and quicker to refer to the explicitly numbered comments rather than counting edit sections.

Below is the portion of my initialization code (just after the require of course). Note, I tend to comment a lot, just my coding style.

Code:
#
# Initialize known_sender to reflect what X-Spam-Known-Sender indicates (i.e., sender is in the Contacts
# list) or for contacts that use subdomains that cannot be exhaustively specified in the Contacts list.
# Note there is also a special case where X-Spam-Known-Sender will be set to "no" even if the contact is
# on the Contacts list. That can happen if there is something bogus in the headers.  When that happens
# "in-addressbook" is added to the end of X-Spam-Known-Sender so that even with "no" it is still known
# it's in the Contacts list.  The known_sender switch being true always guarantees known senders make it
# to through even those with suspicious headers.
#
if header :matches "X-Spam-Known-Sender" ["yes*", "no*in-addressbook*"] {
  set "known_sender" "true";
} elsif address :matches "From" ["*@*abc.tld",         # whitelisted patterns that contacts doesn't support
                                 "*@*xyz.tld",         # if contacts supported full globbing instead of
                                 "*@*.gov",            # just *@domain.tld these tests woudn't be needed.
                                 "*uvwh*"] {
  set "known_sender" "true"; 
} elsif address :matches "To" ["*@LISTSERV.*"] {       # allow subscribed listserv mail lists
  set "known_sender" "true";                           # "To" is the list, "From" is users posting to list
} else {
  set "known_sender" "false";
}
So I then use "known_sender" in places I want to override that might send the message into spam. For example to bypass my black list testing and more to the point to bypass FM own sieve spam check code. So just before section 1 I have:

Code:
#
# Sender is not blacklisted or foreign at this point...
#
# Always bypass the spam score checks for what is considered senders in addition to X-Spam-Known-Sender.
# Unfortunately this also bypasses save-on-SMTP identities and UI generated discard rules but that can't
# be helped since that code below cannot be edited.  Hopefully these will never be important enough for
# known contacts (or whitelisted ones).  If they are then they will have to be explicitly coded.
#
if string :is "${known_sender}" "false" {
And just before section 4 the matching brace to the above test:

Code:
} # not known sender
Hi,

So I have tried this, but everything is now ending up in my inbox. I have traced the error to this line:
HTML Code:
if header :matches "X-Spam-Known-Sender" ["yes*", "no*in-addressbook*"]
and specifically this part:
HTML Code:
"no*in-addressbook*"
For whatever reason, if "X-Spam-Known-Sender" is "no", "known_sender" is being set to "true"

Is there something wrong or out of date with "no*in-addressbook*"?

cheers,
James.
JamesHenderson is offline   Reply With Quote