How to create email filters with KMail

KMail is a feature-rich desktop email client for KDE that is part of the Kontact suite of PIM (Personal Information Management) applications. Last week, we covered email template creation in KMail, and this week, we will continue the series with a look at KMail’s sophisticated filtering system.

An email filter allows you to categorize incoming emails based on a plethora of criteria and then assign them attributes, move them, or even reply to them based on those attributes. KMail provides a good deal of options, making it easy to wade through even large volumes of incoming messages.

Setting up filters in KMail is relatively painless, and once you go through our quick examples, you will be well on your way to the cleanest and most efficient mailbox in your home or office. In this example, we will tell KMail to take all emails sent to tavis at and automatically move them to a special folder within the Inbox. That way, all MakeTechEasier emails will have their own special folder.

To create a new email filter, start KMail or Kontact and follow these instructions:

kmail menu settings filters

1. Click “Settings” in the top menu.

2. Click “Configure Filters”
(The configuration dialog box will appear)

3.  Click “Rename” to change the name of the default filter.

4. Select “Match all of the following” or “…any of the following”. The first will check the message for every rule. The second will continue even if it finds only one of the rules.

Below the “match” criteria you will see three columns of drop-down menus. There is theoretically no limit to the number of rows you can add by pressing the “More” button, but for now, we will only work with one row.

The first column tells KMail which field to extract data from (i.e. Subject, To, Message Body), and for this example choose “To”. The second column tells it how to interpret whatever data it finds (i.e. contains, does not contain, is in category). Leave that on “contains” for now. The final column is where you enter the actual words, numbers, and/or characters that you want the filter to find. In this case, it will be my email address: “tavis”, the “at” sign, and “”.

In the bottom group box, you should see”Filter Actions”, which determines what the filter will do with the message once it has concluded that it matches the criteria. Among the options are Move into Folder, Mark As, and Forward To. For this example, choose “Move Into Folder”. In the second column, click the browse button with the folder icon to the right of it and select the Inbox. Then, click “New Subfolder”, and name it MakeTechEasier.

kmail filter criteria

At the top, click the “Advanced” tab. Here, you can decide if you want the filter to only apply to certain accounts. You can also apply the filter to sent messages, although this setting is disabled by default. The “Add this filter to the Apply Filter menu” is a very important feature. What it does is allow you to institute retroactive filtering. Let’s suppose you have already received 500 emails from MakeTechEasier. This will allow you to apply your new filter to your inbox. It will scan the inbox and move any emails that match your criteria into your new folder. When you are finished configuring your filter, click “OK”. The new filter will start working immediately on any new incoming messages.  If you ever want to add new filters, click the “New filter” button in the bottom left of the settings screen.

kmail filters advanced tab

With KMail’s filtering system, the possibilities are numerous, and they can even become quite complex. The system allows for regular expressions, numerical data, SPAM filtering, and much more. There is also no real limit to the number of filters you can have, making it not only easy to use but also extremely powerful. Next time you get that newsletter from your professional organization and contemplate dragging it to a folder, consider making a filter so that next time, it will already be there. There are many other types of filters. Test them, experiment, and improve your productivity.

Tavis J. Hampton

Tavis J. Hampton is a freelance writer from Indianapolis. He is an avid user of free and open source software and strongly believes that software and knowledge should be free and accessible to all people. He enjoys reading, writing, teaching, spending time with his family, and playing with gadgets.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox