Using Sieve Scripts

Discover our Public Cloud offer

Shared Hosting for Everyone, imagined by developers, for developers.

Discovering the Public Cloud

Sieve is a language for filtering e-mails. It is used to add complex rules that cannot be added via the filtering rules.

Administration interface: E-mails - Script Sieve
Administration interface: E-mails - Script Sieve

The final script is stored in the $HOME/admin/mail/[domain]/[box]/filter_user.sieve file in your account. You can read it to help debug your script, but you cannot edit it.

Extensions supported

ExtensionDescription
bodyChecks the presence of one or more character strings in the e-mail message body
comparator-i;ascii-numericExtracts numbers from the text and compares them to see if it matches
copySpecifies that a copy should be used to perform the action
datePerforms actions based on the date/time when an e-mail is sent/received
duplicateDetects whether it is a duplicate
editheaderAdds or deletes text in the headers
encoded-characterAllows encoding special characters
enotifySends notifications
envelopeAssesses the envelope (“from”, “to”, etc.)
environmentTests different labeled values in the execution environment
fileintoDelivers the e-mail to the specified folder
foreverypartAllows commands to be run in all MIME parts of the e-mail
ihaveTests whether a Sieve extension is available and, if so, executes its action
imap4flagsAdds IMAP indicators and key words to messages
includeUsed to include a Sieve script in another one
indexUsed to match specific header fields by index
mailboxChecks whether a specific directory exists
mimeTests the specific MIME parts in the message
extracttextExtracts text from MIME parts
regexUses regular expressions
rejectRefuses message delivery
relationalAllows relational comparisons
subaddressTests bounded elements in the location part of the addresses
vacationAutomatic answering
variablesUsed to add variables

Examples

Add a <SPAM> prefix to the subject of an e-mail comprising a key word to define (whether in the subject or in the body text)

require ["editheader", "variables", "body"] ;
if allof (
header :contains "subject" "word",
header :matches "Subject" "*"
)
{
deleteheader "Subject";
addheader "Subject" "<SPAM> ${1}";
}
elsif allof (
body :content "text" :contains "word",
header :matches "Subject" "*"
)
{
deleteheader "Subject";
addheader "Subject" "<SPAM> ${1}";
}

Use headers in variables for automatic reponses

require ["variables", "vacation"];

# Store subject header in variable
if header :matches "Subject" "*" {
        set "subj" "**${1}**";
}

# Auto-reply
vacation
  :days 1
  :subject "Out-of-office [Was: ${subj}]"
"Hello,
We've received your last message:

${subj}

We're currently out-of-office and will reply soon.";