View, download and restore your filters as a Sieve script
The filters you create in webmail are stored by the mail server as a single text file: a Sieve script. You can view that script, download it as a file and restore it later. This is handy as a backup, to understand exactly what your filters do, or to take your filters with you to another mailbox.
What is a filter set?
Your filters don't run in webmail but on the mail server, at the moment a message is delivered to your mailbox. They are written in Sieve, a simple language made specifically for filtering mail. You fill in a form in webmail, and webmail turns that into the script.
A filter set is that complete script: all the filters of one mailbox in one file. Your out of office message is in there too, because technically that's also a filter. You can have multiple filter sets, but only one is ever active.
Viewing your filter set
- Log in to webmail and click Settings in the menu and then Filters.
- Click Actions and choose Edit filter set.
You'll now see the script as text. An example as webmail writes it:
require ["fileinto"];
# rule:[Nieuwsbrieven]
if exists "List-Id"
{
fileinto "Nieuwsbrieven";
stop;
}
# rule:[Facturen]
if allof (header :contains "subject" "factuur")
{
fileinto "INBOX.Facturen";
}
# rule:[Collega]
if false # header :contains "from" "collega@example.com"
{
fileinto "INBOX.Team";
}
Here's how to read it:
require ["fileinto"];asks the server for the extension needed to move mail to a folder. Webmail adds this at the top automatically.# rule:[Nieuwsbrieven]is a comment with the name of your filter. That's how webmail recognises your filters.if exists "List-Id"is the condition: the message has a List-Id header, like newsletters and mailing lists do.fileinto "Nieuwsbrieven";moves the message to that folder.stop;means the following filters no longer look at this message.header :contains "subject" "factuur"appears in the form as Subject contains factuur. Upper and lower case don't matter here.if false # ...is a disabled filter. The old condition is kept as a comment after#, so you can switch the filter back on later.
The server reads the script from top to bottom. That's why the order of your filters matters.
Downloading your filter set as a backup
- Go to Settings > Filters.
- Click Actions and choose Download.
You'll get a text file (.txt) named after your filter set. Keep it somewhere safe. That way you have a copy if you accidentally delete a filter, and you can compare if your filters suddenly behave differently. Moving to another mailbox or another server? Then download the script before you cancel the old mailbox.
Restoring a script
- Open the saved file in a text editor, such as Notepad or TextEdit, and copy the entire contents.
- In webmail, go to Settings > Filters > Actions > Edit filter set.
- Select the text that's there, replace it with the copied text and click Save.
- Check the list under Filters to see whether your filters are back, and send yourself a test email to see whether they work.
Everything that was there is replaced by the script you paste. Only want a few filters back? Then copy only those blocks, from the line # rule:[...] up to and including the closing }, and put them in the right place in the existing script. If the pasted part uses an extension that isn't yet listed under require at the top, add it there.
If something in the script isn't right, such as a missing semicolon or curly brace, it won't be saved and you'll get an error message. Your filters then stay as they were.
INBOX.Team. Other mail servers sometimes use a slash (INBOX/Team). If you move a script to another server, or you've renamed folders, check that every folder in the script actually exists. A filter pointing to a folder that doesn't exist won't do what you intend.Good to know
- Per mailbox. A filter set belongs to one mailbox. If you have multiple mailboxes, download the script from each one.
- New mail only. A restored filter works on mail that arrives afterwards. You'll need to move mail that's already in your mailbox yourself.
- Out of office message. If your backup contains an out of office message with old dates, check under Settings > Out of Office after restoring that it's set correctly.
- For the whole domain. Want to set something up for all mailboxes on your domain, such as blocking a sender? Then use the SPAM Filters section in DirectAdmin. See Server-side email rules (filters on the server).
The steps for a new filter can be found in the Roundcube guide under Creating a filter and Examples of useful filters. The language itself is described in RFC 5228.
