Knowledge base
1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Filter incoming emails using the Sieve language
This guide explains how to create sorting rules in Advanced mode, scripts in Sieve language, to automatically classify your incoming emails on Infomaniak according to certain conditions.
âš Available with:
| kSuite | |
| Standard | |
| Business | |
| Enterprise | |
| my kSuite+ | |
| Mail Service | |
| Premium 5 min. addresses |
Preamble
- If you do not have a compatible offer or if you prefer a simplified configuration, refer to this other guide.
- ⚠️ No support is provided regarding the Sieve language (refer to this documentation — also discover the role of the host).
- Unlike the sorting rules offered within email software/clients (Microsoft Outlook, Mozilla Thunderbird, Apple Mail...), these rules will act directly on the server of your mailboxes before even the IMAP connection.
- It is possible to import Sieve files via a button.
- By activating this mode, the existing standard rules will be kept but deactivated.
- The
redirectcommand (allowing to forward an email to another address) is not allowed in scripts.- If you import a Sieve script from another host, make sure to remove this command.
- To forward emails, use the assistant in Standard mode or the Redirections section of your Mail Service.
Access the rules from the Infomaniak Web Mail app
Prerequisites
- Having permission to manage rules: if you had been invited to the Infomaniak Web app Mail (online service ksuite.infomaniak.com/mail) to manage your address, it is possible that the Mail Service manager has removed this right from their admin account.removed this right.
To access the sorting filters for your Infomaniak mailbox:
- Click here to access the Infomaniak Web app Mail (online service ksuite.infomaniak.com/mail).
- Click on the Settings icon ‍ in the top right corner.
- Check or select the email address concerned in the drop-down menu.
- Click on Filters and rules:
‍
Access rules from a Mail Service
To access the sorting filters for your Infomaniak mailbox:
- Click here to access the management of your product on the Infomaniak Manager (need help?).
- Click directly on the name assigned to the product concerned.
- Click on the email address concerned in the table that appears.
- Click on the Rules tab from the left sidebar (or top bar):

Create a new rule in Advanced (expert) mode
Make sure to click on Advanced mode:

First example of advanced sorting
Here is a simple example of a command using this language:
require ["fileinto"];
if address :contains "from" "facebook.com" {
fileinto "fb";
} elsif header :matches "List-Unsubscribe" "*" {
fileinto "nl";
} else {
keep;
}Explanations:
- Loading required extensions: use
require ["fileinto"];to indicate that you will use thefileintofunction. - Filtering Facebook messages: use
if address :contains "from" "facebook.com"to check if the sender's address contains "facebook.com"; if so, the message is filed in the "fb" folder withfileinto "fb";. - Filtering messages with an unsubscribe link: use
elsif header :matches "List-Unsubscribe" "*"to check if the "List-Unsubscribe" header is present in the message; if so, the message is filed in the "nl" folder withfileinto "nl";. - Keeping other messages: use
else { keep; }to keep all other messages that do not match the previous criteria.
Attention:
- If you need to mention a subfolder, use the separator
/(as in the second example), but it is not necessary to specifyINBOXin your codes - Make sure the folders
fbandnlalready exist in your inbox; otherwise, the messages may not be sorted correctly - The filter
address :contains "from" "facebook.com"works correctly for addresses that contain "facebook.com" in the "from" field - The filter
header :matches "List-Unsubscribe" "*"checks only for the presence of the "List-Unsubscribe" header, not its content
Second example of advanced sorting
This code modifies the subject based on thesender (adds a prefix to the subject when an email passes the filter, for example):
require ["fileinto", "editheader", "variables", "regex"];
if address "sender" "owner-scientific-linux-devel at LISTSERV.FNAL.GOV" {
if header :regex "subject" "((Re|Fwd): *)\\[SCIENTIFIC-LINUX-DEVEL\\] *(.*)" {
deleteheader "Subject";
addheader "Subject" "${1}${3}";
} else {
# Ajouter un préfixe si l'objet ne correspond pas déjà au modèle
deleteheader "Subject";
addheader "Subject" "[SL-Devel] ${1}";
}
fileinto "Mail List/SL-Devel";
}Explanations:
- Required extensions:
fileinto: to classify messages into folders.editheader: to modify email headers.variables: to use variables in expressions.regex: for regular expressions.
- Condition on the sender:
if address "sender" "owner-scientific-linux-devel at LISTSERV.FNAL.GOV": checks if the sender matches.
- Condition on the subject:
if header :regex "subject" "((Re|Fwd): *)\\[SCIENTIFIC-LINUX-DEVEL\\] *(.*)": checks if the subject matches the specified pattern.deleteheader "Subject";andaddheader "Subject" "${1}${3}";: deletes the existing subject and adds a new subject with the captured parts.
- Adding a prefix if the subject does not already match the pattern:
addheader "Subject" "[SL-Devel] ${1}";: adds a prefix "[SL-Devel]" to the subject if it is not already present.
- Classifying the message:
fileinto "Mail List/SL-Devel";: classifies messages into the "Mail List/SL-Devel" folder.
Attention:
- Make sure the folder
Mail List/SL-Develalready exists in your inbox. - Check that the script correctly modifies the subject of emails to add or adjust the prefix if necessary.
Link to this FAQ: