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 for the following automatic actions:
- Delete or move messages from email addresses you no longer wish to see.
- Forward emails from a specific email address to your spouse so that both of you receive them.
- Copy messages containing 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 it a template for all the addresses in your Mail Service.
- If you use an email software/client configured in POP, alongside Mail, the messages sorted into folders will no longer be downloaded by your application because the POP protocol only retrieves messages that are in your main inbox. To view the sorted messages, it will be necessary to use the IMAP protocol or only Mail Infomaniak.
Access the rules from the Infomaniak Web Mail app
Prerequisites
- Have a paid email plan (free plans are limited to Standard mode without the ability to create a filter to forward an email to another address, for example).
- Have permission to manage the rules: if you had been invited to the Web app Mail Infomaniak (online service mail.infomaniak.com) to manage your address, it is possible that the Service Mail manager has revoked this right from their admin account.
To access the sorting filters for your Infomaniak mail:
- Click here to access the Web Mail Infomaniak app (online service mail.infomaniak.com).
- Click on the Settings icon ‍ at the top right.
- Check or select the relevant email address from the dropdown menu.
- Click on Filters and rules:
Set up a rule based on a received email
You can also create a rule directly from the received email:
- Click here to access the Web Mail Infomaniak app (online service mail.infomaniak.com).
- Open the message from the sender in question.
- Click on the action menu â‹® at the top right of the opened message.
- Choose Create a rule to open the creation assistant which will be pre-filled with the elements of the message:
‍
Access the rules from the 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 in question.
- Click on the email address concerned in the table that appears.
- Click on the Filters and rules tab from the left sidebar:
Set up filters & sorting rules
Create a new rule in Standard mode
- Click the Add a rule button in Standard mode to create a new rule using a wizard/form:
- The various 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 located at the top right of the table:
These settings can be modified at any time by clicking on the pencil icon ✎ located to the right of the relevant item.
Create a new rule in Advanced (expert) mode
- 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 activating this mode, the existing rules will be kept 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
" and "nl
" already exist in your inbox; otherwise, 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 advanced sorting example
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 sort 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.
- Add a prefix if the subject does not already match the pattern :
addheader "Subject" "[SL-Devel] ${1}";
: adds the prefix "[SL-Devel]" to the subject if it is not already present.
- Message filing :
fileinto "Mail List/SL-Devel";
: files messages into the "Mail List/SL-Devel" folder.
Attention:
- Make sure the folder "
Mail List/SL-Devel
" already exists in your inbox. - Check that the script correctly modifies the subject of emails to add or adjust the prefix if necessary.