The KMail Handbook
Prev | Chapter 3. Using KMail | Next

# 3.5. Filters

After using KMail for a while, you may find that you have trouble sorting out the new messages in your inbox when they arrive. Filters allow you to automatically perform certain actions on incoming messages and to manually perform actions on selected messages in a folder.

Usually, filters are used on incoming messages, but they can also be applied to a message or group of messages. To selectively filter messages in a message folder, select the messages you want to filter and type Ctrl-J or select Message->Apply Filters. Note that this will apply all of your filters to that message; there is no way to apply only certain filters to a message.

If you ever need to remove a filter, select it from the Filter Rules window and press the Delete button.

## 3.5.1. Filter Action

The most common use of filters is to sort incoming messages to certain folders. This can be done by choosing transfer. But there are other actions a filter can start:

- set identity will set your identity if you reply to this message

- set transport will set the method of transport (e.g. SMTP) if you reply to the message.

- transfer will move the message to another folder.

- forward to will forward the message to another email address.

- execute will execute a program, but will not modify the message. Specify the full path to any program you want to execute. KMail will block until the program returns.

- filter app will feed the message to a program. If that program returns output, the entire message (including the headers) will be replaced with this output. If the program doesn't return output, the message won't change. Specify the full path to the program. Be cautious with this action, as it will easily mess up your messages if the filter program does return garbage or extra lines.

## 3.5.2. Filter Examples

If I am subscribed to the KDE User List, I could create a folder for the list (I'll call it KDE-User) and use a filter to automatically transfer new messages from my inbox to my KDE-User folder if they are from the KDE User List. Here is how to create this filter:

1. Think of a unique way of identifying the messages you want to filter. The unique property of my KDE User List messages is that they always contain "kde-user@kde.org" in the To: or Cc: field.

2. Select Settings->Filter Rules....

3. Press the New button to create an empty filter. It will appear as Unnamed.

4. The right side of the Filter window contains two sections: matching criteria and actions. In the matching criteria area, select <To: or Cc:> from the first pull-down menu, contains from the second pull-down menu, and type `kde-user@kde.org` in the text field.

5. Skip down to the actions section. Select transfer from the first pull-down menu. A new pull-down menu containing a list of folders will appear. Select the folder that you want the filtered messages to be transferred to if they match the criteria you selected. For this example, you would select "KDE-User" from the pull-down menu.

You may find that you need to use more complicated criteria to properly filter your messages. For example, you may only want to save the KDE User List messages that are written by your friend Fred Johnson <fj@anywhere.com>. This is where the rest of the matching criteria section comes into play:

1. Open up the Filter Rules window and select the filter you just created.

2. Since you want to filter all messages that have "kde-user@kde.org" in the To: or Cc: field AND that are from Fred, select the and option from the pull down menu between the two criteria sections.

3. Now, go to the bottom criteria section and select the following from the pull-down menus: From, contains. Now, type `fj@anywhere.com` in the text field.

You now have a filter that transfers all KDE User List messages that are from Fred Johnson.

Prev | Home | Next
The Address Book | Up | Multiple Accounts