1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Sort incoming emails according to rules (Sieve filters)
This guide explains how to create sorting rules to automatically classify your incoming emails on Infomaniak according to certain conditions.
Preamble
- These rules allow the following automatic actions:
- Delete or move messages from email addresses you no longer want to see.
- Forward to your spouse emails from an email address so that both of you can receive them.
- Copy messages that contain a specific keyword to a folder.
- etc.
- 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.
- You can make a template for all the addresses of your Mail Service.
- If you use an email software/client configured in POP, in parallel with Mail, messages classified in folders will no longer be downloaded by your application because the POP protocol only retrieves messages that are in your main inbox. To view classified messages, it will be necessary to use the IMAP protocol or only Infomaniak Mail.
Access the rules from the Infomaniak Web Mail app
Prerequisites
- Have a paid email offer (free offers are limited to Standard mode without the possibility of creating a filter to forward an email to another email address, for example).
- Have permission to manage rules: if you had been invited to the Infomaniak Web Mail app (online service ksuite.infomaniak.com/mail) to manage your address, it is possible that the Mail Service manager has revoked this right from their admin account.
To access the sorting filters for your Infomaniak mail:
- Click here to access the Infomaniak Web Mail app (online service ksuite.infomaniak.com/mail).
- Click on the Settings icon in the top right.
- Check or select the email address concerned in the dropdown menu.
- Click on Filters and rules:
Define a rule based on a received email
You can also create a rule directly from the received email:
- Click here to access the Infomaniak Web Mail app (online service ksuite.infomaniak.com/mail).
- Open the message from the sender in question.
- Click on the action menu â‹® at the top right of the open message.
- Choose Create a rule to open the creation assistant which will be pre-filled with the elements of the message:
Access rules from the Mail Service
To access the sorting filters for your Infomaniak mail:
- Click here to access the management of your product on the Infomaniak Manager (need help?).
- Click directly on the name assigned to the product in question.
- Click on the email address concerned in the table that appears.
- Click on the tab Filters and rules from the left sidebar:
Configure filters & sorting rules
Create a new rule in Standard mode
- Click on the button Add a rule in Standard mode to create a new rule using an assistant/creation form:
- The different conditions available for sorting filters are presented in this other guide.
- Once a filter is created, click on Continue to activate it.
Add or modify a rule in Standard mode
If there are already sorting filters, the button to add more is at the top right of the table:
These settings can be modified when you want by clicking on the pencil ✎ icon located to the right of the item in question.
Create a new rule in Advanced (expert) mode
If you don't know what you're doing, it is recommended to stay in Standard mode so as not to disrupt the sorting filters of your account ⚠️ No support is provided regarding the Sieve language (refer to this documentation — also discover the role of the host).
- The advanced mode allows you to configure sorting rules directly from a script in Sieve language.
- It is possible to import Sieve files via the button.
- By enabling this mode, existing rules will be preserved but deactivated.
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 thefileinto
function. - 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.
Warning:
- If you need to mention a subfolder, use the separator
/
(as in the second example), but it is not necessary to specifyINBOX
in your codes - Make sure that the folders
fb
andnl
already 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 file messages in 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.
- Add 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.
- Message classification :
fileinto "Mail List/SL-Devel";
: files messages into the "Mail List/SL-Devel" folder.
Warning:
- Make sure the folder "
Mail List/SL-Devel
" already exists in your inbox. - Check that the script correctly modifies the email subject to add or adjust the prefix if necessary.