Most sorting needs, including in many of these examples, can be better handled by our existing Filters & Rules, subdomain addressing, folder name matching, or aliases.
These examples are provided as a starting point for building up your own custom scripts.
We'd like to thank the Fastmail users who contributed these examples.
File all messages from a recipient into a folder
if address :is "From" "pal@mypals.org" {
fileinto "INBOX.My Best Pal";
stop;
}
File all messages from a domain into a folder
if address :domain :is "From" "mypals.org" {
fileinto "INBOX.Pals";
stop;
}
File all undefined addresses at a virtual domain into a folder
The below example is useful when:
- You have a catchall alias saved for your domain.
- You only want to receive mail to a few addresses at this domain, and think the rest might be spam.
- You would like to save all email that comes to your domain, just in case it is needed.
if allof(
address :domain :is "X-Delivered-To" "mydomain.info",
not address :localpart :is "X-Delivered-To" ["address1", "address2", "address3"] # these are addresses at which you would like to receive email
) {
fileinto "INBOX.Possible spam";
stop;
}
File messages to some aliases into alias-dependent folders
This example is useful for someone who has three aliases at which they would like to receive mail in their Fastmail account, and other aliases for which they would like mail to be redirected to another email account without being saved to their Fastmail mailbox.
One of these aliases, alias2@sent.com, is used only for non-urgent email, for which we would like to mark it read immediately.
if address :is "X-Delivered-To" "alias1@fastmail.fm" {
fileinto "INBOX.alias1";
stop;
} elsif address :is "X-Delivered-To" "alias2@sent.com" {
setflag "\\Seen";
fileinto "INBOX.alias2";
stop;
} elsif address :is "X-Delivered-To" "alias3@eml.cc" {
fileinto "INBOX.alias3";
stop;
}
redirect "another@account.net";
Backup
This Sieve script is useful for sending a backup copy of all email to a different email account, and keeping the rest on your Fastmail account.
redirect "backup@gee-mail.com";
keep;
Do not filter known senders
This example filters all mail except messages from your contacts or from domains you have decided are safe.
if not anyof(
header :contains ["X-Spam-known-sender"] "yes",
header :contains ["from"] ["amazon.co.uk", "myworkdomain.com"]
) {
# ...filtering code goes here...
}