View Single Post
Old 15 Jul 2017, 09:36 AM   #9
camner
Cornerstone of the Community
 
Join Date: Jul 2002
Location: Tacoma, WA
Posts: 642
A followup question related to writing Sieve rules. Currently my sieve rules for discarding mail to known "spammy" targets at my domain looks like this:

Code:
if anyof
      (
       # 1. 'matches' can contain wildcards, 'contains' cannot
         address :matches ["to","from"] 
         [
          "adobe@mydomain.com",
          "adobe1@mydomain.com",
          "adobe2@mydomain.com",
          "adbrs1@mydomain.com",
          and about 50 more!
        ],

       # 2. for partial match but cannot contain wildcards
         address :contains ["to"]
         [
          "info@mydo",
          "sales@mydo"
         ],

       # 3. by header
         #fastmail virus notifications
           header :is ["subject"] ["Infected file rejected"],
           header :contains ["subject"] ["fcyi.pk"],
           header :contains ["subject"] ["Undelivered Mail Returned"],
         #specific attachment
           header :is ["X-Attached"] ["email-info.zip"],
           header :is ["X-Attached"] ["email-text.zip"],
           header :is ["X-Attached"] ["email-doc.zip"],
           header :is ["X-Attached"] ["IMPORTANT.zip"],
           header :contains ["X-Spam-orig-subject"] ["ISO-2022-JP"]
      )
      {discard;stop;}
The #3 block was added a long time ago in response to suggestions on this forum for dealing with certain situations that were generating LOTS of spam in my inbox.

If I want to filter on the Envelope header or the X-delivered-to header, the only way I know to do that would be to add another block in the "anyof" series. But that would force me to repeat all of the nearly 50 email addresses I'm checking for in each block. Is there a fancier way of writing the Sieve code so I only have to list the email addresses once?
camner is offline   Reply With Quote