Filter Examples and Explanations

Mail filters help you organize your email automatically. They can be used to automatically sort your mail into different folders, forward mail to another address, or automatically reply to with another email.

Additionally, we support using SpamAssassin to detect unwanted email and mark it as spam.

How filters work

Filters work by checking parts of each incoming mail message for some particular text, then performing an action if the given text is present. When you create a filter, you tell it what to look for, and what to do if it finds what it was looking for.

Our filters run entirely on the mail server. That means that the actions they perform happen whether you are logged in or not, and happen no matter what mail client you use. This makes it easy to keep your mail settings consistent from anywhere you might use bigimap.com.

What do all these options mean?

There are a lot of options for what text to look for, and several different options for what action to take. Here's a short description for each.

Options for parts of the message:

These tell the filter where to look in the message.

  • Subject - the subject of the message
  • From - the from line in the message
  • To - the values in the To: and Cc: lines in the message
  • Mailing-List - the Mailing-List: header
  • List-Id - the List-Id: header
  • Sent To - who the message was actually sent to (explained further below)
  • Body - the entire message
  • Spam Level - the Spam-Level: header (explained further below)
  • Header >> - whichever header you type in the name of
Options for how to look for text:

These options control how the filter looks for the text.

  • contains - the part of the message being checked has the entered text in it somewhere
  • starts with - the part of the message being checked starts with the entered text
  • does not contain - the part of the message being checked doesn't contain the entered text
  • is - the part of the message being checked matches the entered text exactly.

All text matching is done without regards to uppercase or lowercase. That is, both "help" and "HELP" will match the text "hElP".

Options for the action:

These options tell the filter what to do if it does match the message.

  • Put in folder - This action just puts the message in a specific folder. Nested folders are indicated by Outer-folder-name.inner-folder-name using a "." to separate the folder names. If the specified doesn't exist (it's deleted, for instance), the message will be put in the Inbox as normal.
  • Forward to address - This action forwards the email to the address entered. Be careful with this option, because the normal behavior for this action is to forward the message instead of putting it in any folder.
  • Reply with message - This action causes an automatic reply to be sent, with a couple of conditions. First, only one reply will be sent to the same address each week. Second, automatic replies won't be sent to messages that are either from mailing lists or automatic replies themselves. Also, this action will never prevent standard delivery of a message.

Finally, there's a checkbox below the action which is labeled "After performing this filter, check for more filters that apply to this message." This checkbox requires some background to explain completely.

When an email message arrives on the IMAP server, it goes through the filters to determine what is done with it. First, if SpamAssassin filtering is enabled, the message is run through SpamAssassin. This modifies the message in a couple ways, depending on whether SpamAssassin thinks the message is spam or not. These will be described a bit more in a couple paragraphs.

Second, the message is run through any filters you may have created. It goes through them in order, checking the conditions on each to see if they match. If the email does match a filter's condition, the action in that filter is carried out, then the system considers the mail message successfully delivered. If no filters match, the mail message is put into your Inbox folder.

The checkbox marked "check for more filters" keeps the system from stopping after finding that the filter matched. This means that if the box is checked, taking the given action won't prevent further actions from taking place. This is especially important with forwarding messages, as explained above.

Note that the "Reply with message" action always acts as if the box was checked when that filter was created, to prevent accidently losing messages when you set up an auto-reply.

Some filter examples

Probably the simplest and most common use for a filter is to put mail from different people into different folders. If you have a friend who's email address is joe@cool.com, and you want to put email from him into a folder named "Joe", that is one of the easiest things to do with a filter. Just create a filter that looks for email that where the "From" line "contains" "joe@cool.com", and set the action to put it in the "Joe" folder. If the folder exists already, it can just be chosen from the drop-down list. If it doesn't exist already, just enter the name of the folder in the "Put in new folder", and the folder will be created when the filter added.

Here's a slightly more complex example: suppose you have a phone that can receive email sent to yournumber@yourphonecompany.com, and you're waiting for an important email from yourboss@yourwork.com. What you'd like to do is have the email forwarded to your phone so you get notified that it came in immediately, but you'd still like get the mail in your inbox, too. This is a straightforward case where a single filter can do the job. Create a filter that checks to see if the "From" line "contains" "yourboss@yourwork.com", and if it does, forwards the email to "yournumber@yourphonecompany.com", and make sure to select the "check for more filters" box. The reason to use "contains" is that most email programs put both the person's name and their email address in the "From" line, and so you want it to look for the email address anywhere in the line.

SpamAssassin filtering

When SpamAssassin is enabled, it does some degree of filtering automatically. In particular, it checks messages to see how much they look like spam. If it's above a certain threshhold, SpamAssassin takes some action immediately. It first changes the subject of the message, inserting "***Probable Spam***" at the start of the subject. Then, it replaces the body of the email message with its report on why it thinks the message is spam, and attaches the original body of the message as an attachment, so you can still reach it if it was misidentified.

Additionally, SpamAssassin adds an additional header line to every message it looks at. That line, the "Spam Level" option in the custom filter settings, gives a crude summary of what SpamAssassin thinks of the message. This can be used for additional filtering of stuff that's probably spam, but SpamAssassin isn't sure of.

The header contains SpamAssassin's approximate ranking of the mail, as a number of stars (the * symbol). SpamAssassin automatically takes some action when the number of stars goes to five or more. However, many people have found that most messages with even two stars are probably spam. If you wanted to put all messages that had two stars or more into a "ProbablySpam" folder, you would do that by creating a filter that looked for "Spam Level" "contains" the text "**".

To vs. Sent To

One important remaining point is the difference between the "To" and "Sent To" checks. The basic difference is that the "To" item is the address the author of the email put in. The "Sent To" item is the address that ended up receiving the message. Often, these two values will be the same. Sometimes, though, they aren't.

There are two main cases where the two values can be different. The first is when the email was sent to a mailing list. The "To" value is going to be the email address for the mailing list, and the "Sent To" value is going to be the email address you signed up for the mailing address with. The other case is if you have email automatically being forwarded from one account to another. The "To" value is going to be the account it was initially addressed to, and the "Sent To" value is going to be the address that it was forwarded to.

Usually, it won't matter which of those two you use. For the cases where it does, both options are available.