Last active
March 11, 2026 10:38
-
-
Save mshroyer/0747de73595ecf244852a61402da4435 to your computer and use it in GitHub Desktop.
Fastmail custom Sieve generator to avoid spam filtering on mailing lists
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
| #!/usr/bin/sed -nf | |
| # Generate custom Sieve rules to skip filtering for mailing lists in Fastmail. | |
| # | |
| # Even when you create filters for your subscribed mailing lists, Fastmail | |
| # will apply spam filtering before moving filtered messages to the designated | |
| # folder. This can be troublesome for open source software lists like LKML, | |
| # where things like PATCH messages can be mis-identified as spam. | |
| # | |
| # To use this script: | |
| # | |
| # 1. In your Fastmail filter settings, click "Edit custom Sieve code". | |
| # 2. Click "Copy to clipboard" and save the entire copied contents to a file. | |
| # 3. Run this script on the file with `sed -n`. | |
| # 4. Paste the output into Fastmail's topmost "(Insert Sieve code here)" | |
| # input. | |
| # | |
| # Mark Shroyer | |
| # https://markshroyer.com/contact/ | |
| # 2026-03-11 | |
| 1 { | |
| i\ | |
| # Skip spam filtering for lists we're subscribed to. \ | |
| # \ | |
| # Paste this into Fastmail's topmost "(Insert Sieve code here)" input to \ | |
| # suppress spam filtering for subscribed lists. \ | |
| # \ | |
| # Generated by: \ | |
| # https://gist.github.com/mshroyer/0747de73595ecf244852a61402da4435 \ | |
| if anyof( \ | |
| jmapquery text: \ | |
| { \ | |
| "operator": "OR", \ | |
| "conditions": [ | |
| } | |
| # Only use list IDs in the block corresponding to filters we've manually | |
| # created in the Fastmail UI. | |
| /# Calculate rule actions {{{/ , /# }}}/ { | |
| s/.*\("listId" : ".*"\)/ { \1 },/p | |
| } | |
| # Trailing commas are illegal in Fastmail Sieve code, so finally emit a | |
| # nonsense list ID without one. | |
| $ { | |
| a\ | |
| { "listId" : "no-such-list.example.com" } \ | |
| ] \ | |
| } \ | |
| . \ | |
| ) { \ | |
| set "spam" "N"; \ | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment