Copyright © 1999–2017 FastMail Pty Ltd
- What is sieve?
- Basic sieve guide
- Notify extension
- Special use folders
- Modifying the sieve script
- Sieve supported extensions
- Frequently Asked Questions
- Sieve examples
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. Sieve.info has more information on sieve and its uses.
To create sieve scripts, go to the Mail Settings → 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.
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.
- \Junk - also known as the Spam folder
- \XNotes - the Notes folder
- \XTemplates - the Templates folder
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 some of these, as given below:
- Sieve language reference - fileinto, reject
- Vacation extension
- Vacation seconds Extension
- Relational Tests - relational, envelope, body, comparator-i;ascii-numeric
- Filtering: Variables Extension
- Subaddress Extension
- Copying Without Side Effects
- Regular Expression Extension
- Checking mailbox status and accessing mailbox metadata
- Notify Extension
- Date and Index Extension
- IMAP4flags Extension
- Body Extension
- Editheader Extension
- Detecting duplicates Extension
This is encompassed by the line which appears at the top of your custom sieve script:
require ["fileinto", "reject", "vacation", "imap4flags", "notify", "envelope", "body", "relational", "regex", "subaddress", "copy", "mailbox", "mboxmetadata", "servermetadata", "date", "index", "comparator-i;ascii-numeric", "variables", "editheader", "duplicate", "vacation-seconds"];