Sieve Scripts

What is sieve?

Sieve is a programming language for filtering incoming emails. FastMail's flexible rules system provides most users with filtering functionality, but advanced users may choose to write Sieve scripts for complicated filtering (such as time-based rules, or access to our notify extension).

A sieve script consists of a number of tests which are applied to incoming mail; if a mail matches a test, then the actions associated with that test are performed.

Sieve scripts can be used to automatically delete or forward messages; to send autoreplies; to sort them in folders; to mark messages as read or flagged; to test messages for spam or viruses; or to reject messages at or after delivery. has more information on sieve and its uses.

To create sieve scripts, go to the Advanced → Rules screen and click the "Edit custom sieve code" link. The rules system creates a sieve script behind the scenes, and the advanced rule editing functionality allows you to write additional filtering actions to supplement your existing rules.

Sieve is a powerful language. Only use it if you know what you're doing. It is possible to create a rule which permanently discards mail without the protection of our backup system.

If you're not familiar with sieve, we have a basic sieve guide, including details on how to test your sieve script.

The notify extension

Check out the documentation for the FastMail sieve notify extension which allows you to send information to your devices or other destinations when a matching email arrives.

Special use folders

Some mail clients allow you to rename the system folders, such as Archive and Trash. This can make sieve scripts break if they are using folder names explicitly. Fortunately such folders have a special use flag, allowing you to access them from sieve without needing to know their current titles.

Modifying the sieve script

Many (but not all) of the choices you make in the Settings screens change the your sieve script, not just the Rules screen.

The sieve editing screen prevents you from changing the automatically generated script based on your rules and settings, but leaves you with editable blocks that you may insert your script elements at the right place within the script.

Sieve supported extensions

Sieve has a lot of extensions. FastMail supports a subset of these, as given below:

Note that the final RFCs of these last sieve extensions have significant changes that are not currently supported.