Handy sieve filter examples

Forwardemail, my email provider, supports an incoming “sieve filter”. It’s quite powerful, but there are precious few tutorials on how to write it.
The Fastmail Filter Tester seems to be the best test tool to see what works and what doesn’t. It’s almost compatible with Sieve used by Forwardemail (though Forwardemail’s is a bit more finicky when it comes to regex commands).
Quietly delete incoming email
A simple one to start. This will just delete emails from any email addresses you put in here.
if address :is "from" ["nonsense@example.com","anotherone@example.com"] {
discard; stop;
}
But, you’re probably thinking - I can do this in the fancy GUI of my email program. Why do I want to learn another arcane language?
Well, because I bet you can’t do the below.
File AI autoreplies
If you run a newsletter, you’ve probably seen the AI autoresponses you get from automated email bots. They’ll send you “Makes sense to me”, or “I’ll think about it”, or similar things - to every single email you send.
I unsubscribe them eventually, but I also want to just get them out of my inbox.
This filter rule will watch for a response to the newsletter, and if the first line of the reply is less than 49 characters, followed by a blank line, followed by the word “On”, it’ll filter it into an AI folder.
require ["fileinto", "regex", "body"];
# Remove those short replies from AI
if address :is "to" ["updates@podnews.net","news@podcastbusinessjournal.com"] {
if header :matches "subject" "Re: *" {
if body :content "text/plain" :regex "^.{0,49}\\n.{0,1}\\n[On][On]" {
fileinto "AI"; stop;
}
}
}
Nifty.
More to come, doubtless.