How I use Sieve
I'm hearing it's not easy to start blank with sieve, so I though about sharing my config, heavily redacted for privacy, in the hope it'll help bootstrap yours.
In sieve, you need to declare which extensions you're using, I'm not using a lot:
require ["fileinto", "mailbox", "imap4flags"];
And here are their docs:
fileinto
is native, so see the sieve RFC- imap4flags extension
- mailbox extension
The first rule in my sieve file is a big denylist, that's because I use catchall addresses so I can easily give unique emails to each service. When a service I use gets pwned I just give them another email and denylist the leaked one to stop the spam.
It's kind of funny because I know when a service is pwned: that's when I receive spam on the email I gave them.
if address :is "To" [
"adsense@example.com",
"contact@example.com",
"dropbox@example.com",
"info@example.com",
"last.fm@example.com",
"lightroom@example.com",
"www.adobe.com@example.com"
] {
discard;
}
contact
and info
are not from leaks, but you guess why they
receive a lot of spam, that's the big issue with catchall addresses:
you receive spam on emails addresses that had never existed just
because spammers are trying.
A better way to handle that is to use aliases with wildcards like:
tmp-*@example.com
, and when you create an account give an address
starting with tmp-*
. This way you won't receive spam sent to
info@
, contact@
and all those things.
All the following sieve sections are elsif
blocks, that's because I want the flow to
be dumb easy to understand.
So the next one is here because I'm moderator of a few mailing lists,
so I receive some "post by ... requires approval", "The list has 1
moderation requests waiting", I put all those mails in an
Administrativia
IMAP directory:
elsif anyof(
header :is "X-List-Administrivia" "yes",
allof(header :contains "subject" "post from",
header :contains "subject" "requires approval"),
allof(header :contains "subject" " list has ",
header :contains "subject" "moderation requests "),
header :contains "subject" "s subscription disabled on ") {
fileinto "ml/Administrivia";
}
Then I have sections about blocking some "mailing list" that hard "hard to unsubscribe", it looks like:
elsif header "From" "We're cool <not-cool-startup@example.com>" {
discard;
}
elsif address :domain "from" "not-nice-startup.com" {
discard;
}
Next sections are about automatically classifying things to IMAP folders, this is the biggest section of my sieve filters:
elsif address :is "To" "julien+rss2email@example.com" {
fileinto "rss2email";
}
elsif header :contains "subject" "cron.weekly issue" {
fileinto "rss2email";
}
elsif header :is "X-Mailer" "Gitea" {
fileinto "git";
}
elsif header :contains "List-Id" "bluehats.lists.sr.ht" {
fileinto "ml/bluehats";
}
elsif header :contains "list-id" "python-ideas.python.org" {
fileinto "ml/py/ideas";
}
elsif header :contains "list-id" "python-committers.python" {
fileinto "ml/py/committers";
}
I have tons and tons of those, let's not bother you with the full text :D
Just in case there's mailing list you're no longer actively reading but yet want to keep them for a bit, you can mark mails as read for this directory:
elsif header :contains "list-id" "lurking-on.a.mailing.list" {
addflag "\\Seen";
fileinto "ml/lurking";
}
The final section is quite important to keep my inbox readable, it
dispatch unimportant emails to an other
directory, while keeping
spam ... to the spam directory even if they match the other
rule!
elsif header :contains "X-Spam" "Yes" {
fileinto "Junk";
}
elsif address :contains "to" "undisclosed-recipients" {
fileinto "other";
}
elsif exists "list-unsubscribe" {
if not anyof(
header :contains "From" "afpy-discuss@example.com",
address :is "From" "children-school@example.com"
) {
fileinto "other";
}
}
Mails with list-unsubscribe
probably don't deserve my inbox, same
for mails sent to undisclosed-recipients
, so they go to other
,
which I read way less often and with way less attention.
But a few mails have a list-unsubscribe
and yet I want to get them
in the inbox, like when they're sent by my child's school, that's why
you're seeing an if not anyof
inside the elif exists
"list-unsubscribe"
to save them.