Skip to content

Instantly share code, notes, and snippets.

@mshroyer
Last active March 11, 2026 10:38
Show Gist options
  • Select an option

  • Save mshroyer/0747de73595ecf244852a61402da4435 to your computer and use it in GitHub Desktop.

Select an option

Save mshroyer/0747de73595ecf244852a61402da4435 to your computer and use it in GitHub Desktop.
Fastmail custom Sieve generator to avoid spam filtering on mailing lists
#!/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