---
title: "Improving mail filter performance"
date: "2014-11-17"
category: "email"
slug: "improving-mail-filter-performance"
---

## Overview

Incoming e-mail passes through several filtering stages before delivery:

- [DNSBL lookups](http://www.dnsbl.info/) on handshake
- [Deep protocol](http://www.postfix.org/POSTSCREEN_README.html) inspection
- [DomainKeys](http://en.wikipedia.org/wiki/DomainKeys)/[SPF](http://www.openspf.org) validation
- [SpamAssassin](http://spamassassin.apache.org) filtering
    - Whitelist management
    - Hash-sharing systems ([DCC](http://www.rhyolite.com/dcc/) & [Razor](http://razor.sourceforge.net/))
    - Token-based regex matching
    - Markup filtering
    - **[Bayesian](http://en.wikipedia.org/wiki/Bayes'_theorem) filtering**

All steps are automated except **Bayesian filtering**, which improves through both automatic and manual training.

## How Bayesian Filtering Works

Bayesian filtering breaks each e-mail into individual words and compares word frequency between known spam and legitimate mail. Words that appear frequently in spam (e.g., "Viagra", "Solar Panels") increase the spam score. Words common in legitimate mail decrease it, making those messages less likely to land in your [[accessing-spam-folder]].

## Training the Filter

### Using the AutoSpam IMAP Folder

For accounts using [[pop3-vs-imap-e-mail-protocols]], create an IMAP folder called `AutoSpam` (capitalization matters). Drag and drop spam that slipped through into this folder. Messages are analyzed nightly and discarded after training.

### Creating AutoSpam via the Control Panel

1. In the control panel, go to **Mail** > **SpamAssassin Config**
2. Click **Enable Folder** under Feedback Participation
3. Log out and back into your IMAP client to see the new folder

![Drag and drop learning with the AutoSpam folder](kb-image:autospam-learning-folder.gif)
*Drag and drop learning with the AutoSpam folder*

## Guidelines

- Do not feed the filter e-mails from mailing lists you subscribed to -- use the unsubscribe feature instead
- Do not poison the filter by marking legitimate mail as spam
- Results take up to 24 hours to incorporate into the filtering algorithm
