The Anti-Spam Wizard


KMail does not have a built-in spam detection solution: the developers believe using external, but specialized, tools is the better approach. KMail uses these tools through its flexible filter architecture. The Anti-Spam Wizard helps you with the initial filter setup.

What can the wizard do to help you?

It will give you some choices about how you want the spam filtering to be set up. Afterwards it will automatically create the appropriate filter rules.

What are the limitations of the wizard?

It can only initially set up the filters for you; and it will provide a standard setup. Manual modifications in existing filters are not considered. Instead, these filters are overwritten by the wizard.

You can activate the wizard via ToolsAnti-Spam Wizard....

The wizard scans for known anti-spam tools on your computer. It is also possible to use the results of spam checks made by your service provider by evaluating header information which has been added to the messages. You can let the wizard prepare KMail to use one or more of these in parallel. However, note that anti-spam tool operations are usually time consuming. KMail can appear to be frozen during the scan of messages for spam; you may encounter problems with the responsiveness of KMail. Please consider deleting the filter rules created by the wizard if the filtering becomes too slow for you. Here are some recommendations regarding the supported tools:


Bogofilter is a bayesian filter, that means its spam detection relies on an initial training phase. On the other hand, it's a pretty fast tool. That's why it is recommended to be used by people who primarily want to have fast spam detection, and who won't worry about the initial training before the detection rate increases significantly.


SpamAssassin is a pretty complex tool to use against spam. Although its behavior depends heavily on its configuration, it can detect spam quite well without any training. However, scanning a message takes a little longer compared to pure bayesian filters. Let's say it's not the tool of choice for people without some background information about SpamAssassin's capabilities.


Perhaps not so often used until distributions pick it up. It's clearly a tool for specialists.

GMX Spam Filter

If you get your mail via the GMX freemail provider, your messages are already scanned for spam. The result of that process is documented in a special header field of each message. It's possible to use the content of this header field to sort out spam. There is no slowdown in the filtering if only this tool is used, as the messages have already been processed.


Here are the details of how the wizard works: KMail can use several external tools to detect spam messages; it will try to automatically find out which tools are installed on your system and will show you these in a list. The list is ordered by the average speed of the filtering process of the tools. You can mark the tools which you want to be used by KMail to detect spam. Of course, you can close the wizard, install a new tool, and restart the wizard again.

If you have marked at least one tool, KMail is able to provide filters which allow the classification of the messages as spam or not spam. It will also provide actions to let you manually classify messages. These actions will be available via the menu and toolbar icons. If any of the tools you selected support Bayesian filtering (i.e. a method to detect spam based on statistical analysis of the messages) then these messages are not only marked but additionally transferred to the tools to enable them to learn thereby improving their detection rate.

On the second page, you will be able to select some additional actions to be performed in KMail with regard to spam messages: if you want messages detected as spam to be moved into a certain folder, select the appropriate folder and mark the Move known spam to: option; if messages detected as spam should additionally be marked as read, then mark the Mark detected spam messages as read option.

Selecting at least one of the available tools will allow the wizard to finish the filter setup. The wizard will not take any modifications in existing filters, formerly created by it, into consideration but will either append new filters or replace existing filters. In any case you may want to inspect the result of this process in the Filter Dialog. The wizard will also create toolbar buttons for marking messages as spam or as ham; keep in mind that classifying messages as spam will also move those messages to the folder you had specified for spam messages, if you have selected the appropriate option.

Some More Details for Experts

The wizard uses information stored in a special configuration file named kmail.antispamrc (stored in the global or local KDE config directory). It will first check the global config file and then the local config file: if the local config file contains entries with higher (newer) version numbers per-tool the configuration data from the local file for that tool is used; that way, both administrators and users can update the wizard configuration.

The local detection of spam messages is achieved by creating pipe through actions per-tool within a special filter. Another filter contains rules to check for detected spam messages and actions to mark them and (optionally, depending on the choice in the wizard) to move them into a folder. Both filters are configured to be applied on incoming messages and on manual filtering.

Two filters are needed for the classification of ham and spam. They contain actions to mark the messages appropriately. As mentioned above, the filter for classification as spam can have another supplementary action to move the messages into a predefined folder. If the selected tools support Bayesian filtering, the wizard will create additional filter actions to pass the messages to the tools (via execute command actions) in the appropriate learning mode.

If you want to fine-tune the filtering process, you might be interested in the chapter about Filter Optimization.