Sieve filters: introduction and activation
Sieve is a standard mail filtering language (RFC 5228). ITProMail runs your Sieve scripts on the server when mail arrives, so the rules apply to every client, including webmail and phones, and do not depend on your computer being on. Sieve is available on the Operator and Shadow plans, and each account can store up to 10 scripts.
Where filters live
Open Account > Filters to create, edit and activate scripts. A script is a set of rules. Rules run from top to bottom, and each incoming message passes through the script once.
Syntax basics
- Commands end with a semicolon.
- Strings are enclosed in double quotes.
- A script that uses extensions starts with a
requireline that lists them. Core actions such askeep,discardandstopneed no entry. - Conditions use
if,elsifandelse. Actions go inside braces. - Comments start with
#. - Header tests are case-insensitive by default.
Common tests include header, address, size, exists, anyof, allof and not. Common actions include fileinto (file into a folder), redirect (forward), discard (drop silently), keep (deliver to Inbox), stop (end processing) and vacation (automatic reply).
A small first script looks like this:
require ["fileinto"];
# Send list traffic to its own folder
if header :contains "List-Id" "dev.example.org" {
fileinto "Lists";
}
Create and activate a script
- In Account > Filters, create a new script and give it a name that describes its purpose.
- Write or paste the rules. Keep scripts short and comment them.
- Create any folders the rules file mail into before you activate the script, so mail lands where you expect.
- Save the script, then activate it. Sieve allows only one active script at a time, so activating a script replaces the one that was active before. Keep all your rules in that script, or merge them into it.
Test before you rely on it
Send a test message from another address that should match the rule, then check the target folder. Look at the raw headers of a real message to confirm the exact header name and value you are matching. Start with narrow conditions. A rule that matches too broadly can file or discard real mail.
Next steps
See Sieve examples for ready-made rules, and forwarding and automatic replies for the redirect and vacation actions.