4.5 Create Rules to Automatically Organize Mail

Filters work very much like the mail room in a large company. Their purpose is to bundle, sort, and distribute mail to the various folders. In addition, you can have multiple filters performing multiple actions that might effect the same message in several ways. For example, your filters could put copies of one message into multiple folders, or keep one copy and send one to another person.

4.5.1 Creating New Filter Rules

  1. Click Edit > Message Filters.

  2. Click Add.

  3. Type a name for the filter in the Rule name field.

  4. Define the criteria for the filter in the If section.

    For each of the filter criteria, you must first select which parts of the message you want to filter:

    Sender: The sender's address.

    Recipient: The recipients of the message.

    Subject: The subject line of the message.

    Specific Header: Any header including custom ones.

    If a message uses a header more than once, Evolution pays attention only to the first instance, even if the message defines the header differently the second time. For example, if a message declares the Resent-From: header as “engineering@example.com” and then restates it as “marketing@example.com”, Evolution filters as though the second declaration did not occur. To filter on messages that use headers multiple times, use a regular expression.

    Message Body: Searches in the actual text of the message.

    Expression: (For programmers only) Match a message according to an expression you write in the Scheme language, used to define filters in Evolution.

    Date Sent: Filters messages according to the date on which they were sent. First, choose the conditions you want a message to meet, such as before a given time or after a given time. Then choose the time. The filter compares the message's time stamp to the system clock when the filter is run, or to a specific time and date you choose from a calendar. You can also have it look for a message within a range of time relative to the filter, such as two to four days ago.

    Date Received: This works the same way as the Date Sent option, except that it compares the time you received the message with the dates you specify.

    Label: Messages can have labels of Important, Work, Personal, To Do, or Later. You can set tables with other filters or by hand.

    Score: Sets the message score to any whole number greater than 0. You can have one filter set or change a message score, and then set up another filter to move the messages you have scored. A message score is not based on anything in particular: it is simply a number you can assign to messages so other filters can process them.

    Size: Sorts based on the size of the message in kilobytes.

    Status: Filters according to the status of a message. The status can be Replied To, Draft, Important, Read, or Junk.

    Flagged: Checks whether the message is flagged for follow-up.

    Attachments: Creates a filter based on whether there is an attachment for the e-mail.

    Mailing List Filters based on the mailing list the message came from. This filter might miss messages from some list servers, because it checks for the X-BeenThere header, which is used to identify mailing lists or other redistributors of mail. Mail from list servers that do not set X-BeenThere properly are not be caught by these filters.

    Regex Match: If you know your way around a regex, or regular expression, this option allows you to search for complex patterns of letters, so that you can find, for example, all words that start with a and end with m, and are between six and fifteen letters long, or all messages that declare a particular header twice. For information about how to use regular expressions, check the man page for the grep command.

    Source Account: Filters messages according the server you got them from. This is most useful if you use multiple POP mail accounts.

    Pipe to Program: Evolution can use an external command to process a message, then process it based on the return value. Commands used in this way must return an integer. This is most commonly used to add an external junk mail filter.

    Junk Test: Filters based on the results of the junk mail test.

    Select the Criteria for the Condition: If you want multiple criteria for this filter, click Add Criterion and repeat step 4.

    Select the Actions for the Filter in the Then Section: Select any of the following options.

    • Move to Folder: Moves the message into a folder you specify. Click Here to select the destination folder.

    • Copy to Folder: Puts a copy of the message into a folder you specify. Click Here to select the destination folder.

    • Delete: Marks the message for deletion. The message can be undeleted until you expunge or empty the trash.

    • Stop Processing: Select this if you want to have all other filters ignore this message.

    • Assign Color: Marks the message with a color of your choice.

    • Assign Score: Assigns the message a numeric score.

    • Adjust Score: Changes the numeric score by the amount you set.

    • Set Status: Sets the status of the message. The status can be Replied To, Draft, Important, Read, or Junk.

    • Unset Status: If the message has a status value, unsets it. If a status value is not set, it does nothing.

    • Beep: Makes the system beep.

    • Play Sound: Select a sound file for Evolution to play.

    • Pipe to Program: Sends the message to a program of your choice. No return value is expected. This feature can be used to create automatic Web postings from e-mail messages or to perform additional message post processing not supported by Evolution.

    • Run Program: Evolution runs an application.

  5. Click Add Action if you need multiple actions and click OK.

  6. Click OK.

There is an easy shortcut for fast filter or search folder creation:

  1. Right-click the message in the e-mail list.

  2. Select one of the items under the Create Rule from the Message submenu.

    Creating a rule based on a message opens the filter creation tool with some of the information about the message already filled in for your convenience.

If you have several filters that match a single message, they are all applied to the message in order, unless one of the filters has the Stop Processing action. If you use that action in a filter, the messages that it affects are not touched by other filters.

When you first open the Filters dialog box, you are shown the list of filters sorted in the order in which they will be applied. You can move them up and down in the priority list by clicking the Up and Down buttons.

4.5.2 Editing Filters

  1. Click Edit > Message Filters.

  2. Select the filter to edit, then click Edit.

  3. Make the desired corrections, then click OK twice.

4.5.3 Deleting Filters

  1. Click Edit > Message Filters.

  2. Select the filter to remove, then click Remove.

  3. Click OK.