Sieve frequently asked questions

Sieve is a powerful tool for filtering your messages and gives you complete control over what happens to messages when they arrive in your account. This is a list of all the most frequently asked questions relating to Sieve.

For information on how to set up Sieve in your account, see our Using Sieve scripts in Fastmail help page.

Using Sieve

Can I use Sieve to filter messages I send?

No, Sieve only scans incoming messages.

I use a mail client — can I still use Sieve?

Yes, Sieve scripts are run on the server before the message is delivered to your account. Whether you use the web interface or an IMAP/POP client, your Sieve scripts will still work.

Do I have to log in to the web interface to edit my script?

Yes, the only way to modify your script is by logging in to the web interface. Fastmail does not support the "managesieve" extension.

Filing mail

Messages are filed into one folder and I want them filed in multiple folders (or vice-versa).

Use stop, else, and elsif to stop execution or to only execute one of several alternatives.

Messages are filed to the Inbox where they should be filed to a folder.

Make sure you typed the folder name correctly (INBOX. followed by a copy-paste of the name in the Settings → Mail Rules screen, or just INBOX for the Inbox). Folder names are case-sensitive. In addition, if you've renamed a folder, make sure to update your relevant Sieve scripts; otherwise, messages intended for the renamed folder will be filed into the Inbox.

Why do I get copies in the Inbox when using forwarding rules?

Use the copying without side effects extension. For example, use:

redirect :copy "jcitizen@example.org";

Do I have to create two rules if I want to file a message into two folders?

No, just add a second fileinto (or any other action) immediately after the first one.

Matching

I want to match messages to the domain with catchall, unless they were sent to a specific localpart.

Make sure the tests for specific localparts are placed before the catchall test.

How do I match an exact string?

Use the :is comparator (instead of :contains). If you prefer regexes, the characters matching start- and end-of-string are ^ and $, respectively.

Matching empty and non-existent fields.

The exists test should be used to test for the existence of a field in the header; it is equivalent to the test not header :contains "X-Field-Name" "". One way to describe an empty field is header :is "X-Field-Name" "" (alternative forms use regex or :matches with exists).

WARNING: Matches to "" sometimes don't work where they should.

How do I apply an action to all messages?

Use the true test (example: if true { /* Do action */ }), or don't use a test at all (remove the if, the test, and the brackets from the previous example). In the GUI, the "Always" test is available.

Are there Fastmail-specific header fields I can use in my script?

Fastmail adds several headers to incoming mail. See email delivery headers for detailed information on the headers and their expected values.

We also support S/MIME signing, with fields inside the Authentication-Results header.

Actions

I already have a script. I want to forward all my mail to a backup account. How do I do this?

Make sure that either an explicit keep or a fileinto, but not both, are executed for every message (this is in addition to the redirect).

Can I add IMAP flags to messages from a Sieve script?

Yes. The imap4flags extension is supported.

To mark a message read, IMAP deleted ("crossed out"), or flagged, use addflag "\\Seen", addflag "\\Deleted", and/or addflag "\\Flagged", respectively.

Can I add special notifications for my mobile app?

Yes. Use the syntax addflag "$notify"; to send a push notification to the Fastmail app for messages matching that filter.

Can I modify the header or body of a message with Sieve?

Yes, we support the Editheader extension.

Can I reject messages before delivery (before SMTP DATA)?

No. Fastmail runs Sieve after the SMTP connection is closed (delivery process).

Testing and troubleshooting

How do I test my script without sending lots of messages?

You can test your scripts using our Sieve tester.

Examples

Do you have any examples of Sieve scripts?

We have some examples available here.

Was this article helpful?
5 out of 9 found this helpful