Overview
Sieve is a scripting language for filtering and modifying email messages. Rather than inventing a proprietary DSL, Stalwart uses Sieve because it is an established internet standard well suited to the range of filtering and transformation tasks encountered in email delivery.
A Sieve script consists of one or more rules, each combining a test and an action. The test inspects an attribute of the message, such as the sender's address or the subject line; the action specifies what to do when the test matches. This documentation focuses on how Sieve is integrated into Stalwart (interpreters, variables, expressions, function reference, examples) rather than on Sieve syntax itself; tutorials covering the language are collected at sieve.info.
Stalwart extends the standard Sieve language with its own expression syntax and a rich set of built-in functions for DNS queries, directory lookups, SQL queries, hashing, image and MIME inspection, and more, all accessible from the eval, let, and while instructions.
The Sieve interpreter included in Stalwart supports the following extensions:
- RFC 5228 - Sieve: An Email Filtering Language
- RFC 3894 - Copying Without Side Effects
- RFC 5173 - Body Extension
- RFC 5183 - Environment Extension
- RFC 5229 - Variables Extension
- RFC 5230 - Vacation Extension
- RFC 5231 - Relational Extension
- RFC 5232 - Imap4flags Extension
- RFC 5233 - Subaddress Extension
- RFC 5235 - Spamtest and Virustest Extensions
- RFC 5260 - Date and Index Extensions
- RFC 5293 - Editheader Extension
- RFC 5429 - Reject and Extended Reject Extensions
- RFC 5435 - Extension for Notifications
- RFC 5463 - Ihave Extension
- RFC 5490 - Extensions for Checking Mailbox Status and Accessing Mailbox Metadata
- RFC 5703 - MIME Part Tests, Iteration, Extraction, Replacement, and Enclosure
- RFC 6009 - Delivery Status Notifications and Deliver-By Extensions
- RFC 6131 - Sieve Vacation Extension: "Seconds" Parameter
- RFC 6134 - Externally Stored Lists
- RFC 6558 - Converting Messages before Delivery
- RFC 6609 - Include Extension
- RFC 7352 - Detecting Duplicate Deliveries
- RFC 8579 - Delivering to Special-Use Mailboxes
- RFC 8580 - File Carbon Copy (FCC)
- RFC 9042 - Delivery by MAILBOXID
- REGEX-01 - Regular Expression Extension (draft-ietf-sieve-regex-01)