Last active
April 15, 2025 08:11
-
-
Save jsit/b19b12176d5a4cefba3779d25aba53e1 to your computer and use it in GitHub Desktop.
Notifications / mailing lists / bulk email sieve code (for e.g. Fastmail et al.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if | |
# Tests for "Mailing Lists" | |
anyof( | |
header :is "X-ME-VSCategory" "community:mailing-list", | |
header :contains "X-Mailer" "Sympa", | |
exists [ | |
"List-Id", | |
"List-Help", | |
"List-Subscribe", | |
"List-Unsubscribe", | |
"List-Post", | |
"List-Owner", | |
"List-Archive" | |
], | |
allof( | |
not header :contains ["From", "Reply-To", "Received-From", "Return-Path"] [ | |
"github.com", # github.com notifications use "list-archive" et al. | |
"substack.com" # substack notifications use "list-archive" et al. | |
], | |
header :contains [ | |
"List-Archive", | |
"List-Post", | |
"X-no-archive" | |
] "" | |
) | |
) | |
{ | |
fileinto "INBOX.Mailing Lists"; | |
} | |
elsif | |
# these are DEFINITELY notifications | |
allof( | |
anyof( | |
header :contains "X-ME-CMCategory" "notification", | |
header :contains "X-ME-VSCategory" "transactional" | |
), | |
# unless they're from substack, which does "transactional" for some reason | |
not header :contains ["From", "Reply-To", "Received-From", "Return-Path"] [ | |
"substack.com" | |
] | |
) | |
{ | |
fileinto "INBOX.Notifications"; | |
} | |
elsif # Tests for "Newsletters" | |
allof( | |
anyof( | |
exists "X-Mailgun-Batch-Id", | |
header :is "X-Mailgun-Tag" "bulk-email", | |
exists "x-bulkmail", | |
exists "X-EmailOctopus-List-Id", | |
allof( | |
header :is "Precedence" "bulk", | |
header :contains [ | |
"List-Unsubscribe", | |
"list-unsubscribe" | |
] "" | |
), | |
allof( | |
header :is "precedence" "list", | |
header :contains [ | |
"x-abuse-info", | |
"x-complaints-to" | |
] "" | |
), | |
allof( | |
exists [ | |
"List-Id", | |
"List-Unsubscribe" | |
], | |
header :contains ["From", "Reply-To", "Received-From", "Return-Path"] [ | |
"buttondown.email", | |
"tinyletterapp.com" | |
] | |
), | |
allof( | |
header :contains "X-ME-VSCategory" "commercial:mce", | |
anyof( | |
allof( | |
header :contains "X-ME-CMCategory" "promotion", | |
anyof( | |
# exists "List-Unsubscribe", # too greedy | |
exists [ | |
"List-Unsubscribe", | |
"X-CSA-Complaints" | |
] | |
) | |
), | |
header :contains ["From", "Reply-To", "Received-From", "Return-Path"] "ghost.io", | |
# header :contains [ # too greedy | |
# "list-unsubscribe", | |
# "list-id" | |
# ] "", | |
exists [ | |
"List-Unsubscribe", | |
"List-Id", | |
"X-CSA-Complaints" | |
], | |
exists [ | |
"list-unsubscribe", | |
"X-Report-Abuse" | |
] | |
) | |
), | |
header :contains "List-Unsubscribe" [ | |
"listmanager", | |
"convertkit", | |
"kmail-lists", | |
"buttondown" | |
], | |
header :contains [ | |
"X-Campaign", | |
"X-campaignid", | |
"X-maillist-guid", | |
"X-maillist-id", | |
"X-MC-User", | |
"X-Unsubscribe-Web", | |
"X-rpcampaign", | |
"List-Unsubscribe-Post" | |
] "", | |
allof( | |
exists [ | |
"List-ID", | |
"List-Unsubscribe" | |
], | |
header :contains [ | |
"X-CSA-Complaints", | |
"X-Direct-Mail-Bounce", | |
"X-Direct-Mail-Abuse" | |
] "" | |
) | |
) | |
) | |
{ | |
fileinto "INBOX.Newsletters"; | |
} | |
elsif | |
# Tests for Notifications | |
anyof( | |
allof( | |
header :contains "X-ME-VSCategory" "community:social", | |
header :value "gt" :comparator "i;ascii-numeric" "X-ME-VSScore" "9" | |
), | |
allof( | |
# usually list-unsubscribe is for mailing lists, but we've | |
# already done our filter for that | |
header :contains "X-ME-VSCategory" "mce", | |
exists "list-unsubscribe" | |
), | |
allof( | |
header :contains "X-ME-CMCategory" "promotion", | |
header :contains "X-ME-VSCategory" "clean" | |
), | |
header :contains "X-ME-VSCategory" "commercial:mce", | |
exists "X-Auto-Response-Suppress", # Xfinity | |
exists "X-eBay-MailTracker", | |
exists "X-Relaying-Domain", | |
header :contains ["Return-Path", "Received"] [ | |
"ddsservicebureau", | |
"opensolutionsasp", | |
"messageprovider.com", | |
"billsupport.com", | |
"[email protected]" | |
], | |
header :contains "X-Mailer" [ | |
"MIME-tools", | |
"PHPMailer" | |
], | |
header :contains "X-Spam-source" "reflexion.net", | |
header :contains [ | |
"List-Unsubscribe", | |
"Auto-Submitted", | |
"X-CSA-Complaints", | |
"X-Complaints-To" | |
] "", | |
header :contains ["From", "Return-Path", "Received", "Reply-To"] [ | |
"amazonses.com", | |
"att-mail.com", | |
"customercenter.net", | |
"customeriomail.com", | |
"diginsite.net", | |
"emailnotify.net", | |
"exacttarget.com", | |
"lithium.com", | |
"mailgun", | |
"mcdlv.net", | |
"reflexion.net", | |
"rsgsv.net", | |
"sac.fedex.com", | |
"salesforce.com", | |
"sendgrid.net", | |
"[email protected]", | |
"sparkpost", | |
"wordfly.com" | |
], | |
address :contains :localpart ["from", "all", "return-path", "reply-to", "X-Mail-from"] [ | |
"donotreply", | |
"do-not-reply", | |
"do_not_reply", | |
"DoNotRespond", | |
"donotrespond", | |
"no-reply", | |
"noreply", | |
"notification", | |
"notifications" | |
] | |
) | |
{ | |
fileinto "INBOX.Notifications"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment