Custom filters — Explanation of the message filter fields

 

Overview

This article explains the different fields you can add when creating a mail filter on the Message Filters page in your panel. See this article article for further details.

The following should be taken into consideration when creating filters:

  • Order matters! The rules are checked in order, so make sure they are listed in the order you want them to be executed.
  • Most rules should end with execute and stop. Only use execute and continue if you wish to perform multiple actions to a single incoming email.

How the 'execute and stop' rule works

This rule only applies in certain circumstances:

  • When it applies — If a rule performs a delivery action such as moving the email to a folder.
  • When it does NOT apply — If a rule performs a non-delivery action such as adding text to the Subject. In this case, the filter continues to the next rule until the final delivery action.
Rule Result Explanation

Rule #1:

  • When an email's: 'Subject contains testing'
  • Add this to the subject: FILTERED
  • If this filter matches: execute and stop

 

Rule #2:

  • When an email's: 'From contains example.com'
  • Move it to folder: filterfolder
  • If this filter matches: execute and stop

The text FILTERED is added to the subject, but the filter continues to the second rule.

The email is then moved into the folder.

Since the first rule did not perform a delivery action, the filter continued on to the second rule which did.

Additional rules will not execute since the second rule performed the delivery action.

List of optional fields

This table describes the different fields you can add when creating a custom filter.

Field Explanation Example

Subject

Matches part or all of the Subject.

match drink in Subject: Eat, drink, and be merry!

From

Matches part or all of the From line.

match Jones in From: Bob Jones

To

Use * before your term to match anywhere in the line.

match George in To: George of the Jungle

match *Jungle in To: George of the Jungle

CC

Searches the CC line(s) of the email, checking for other people the email was sent to. N/A

Headers

Searches the beginning of every line in the header.

Use * before your term to match anywhere in the line.

match X-Spam: Yes in the email's headers

match *bananas to match bananas anywhere in any line of the header

Reply-To

Searches the Reply-To line of the email for the email address where replies to the email are sent. N/A

Body

Searches the body of the email. N/A

 

Options within the 'Do this' section

Move it to folder

This places the email in the specified folder. Note the following:

  • Folder names are cAsE sEnSiTiVe. Double-check the name of your folder.
  • Folder names with spaces cannot be used.
  • Subfolders must be specified with the parent folder and a period (e.g. ParentFolder.SubFolder).
  • Folder names can only contain letters, numbers, underscores, dots, and dashes.
  • Folder names cannot contain leading dots, trailing dots, or double dots.

Add this to the subject

Adds the specified text to the beginning of the email's subject line.

Add this header

Adds the specified text to the header area of the email. This added text will not be visible when the email is displayed normally – it will only be visible when viewing the headers.

Forward to shell account

This forwards the email to the /Maildir directory of a shell user. You can then control what happens to the email received by the shell user by creating a .forward.postfix file in your user's home directory.

Configuring a .forward.postfix file

Add a line similar to the following to your .forward.postfix file to run a file when the email is received. Use this syntax:

  • Enclose the command in double quotes
  • Add the | character followed by the full path to the file.
  • Make sure to change username to your shell user.

For example, this runs a script titled myscript.sh:

"| /home/username/myscript.sh"

Set the following permissions:

Delete it

The email is permanently erased. It is not placed in the Trash folder.

Checking multiple fields

You can add multiple filters to a single email address.

Each filter can use multiple rules but can only perform a single final action. Options are:

  • Execute and continue
  • Execute and stop

Use "execute and continue" to check multiple fields within an article such as 'Subject', From, or Headers. 

If a filter is created with "execute and stop", the first rule that matches will be the last action taken, and additional filters will not be checked.

Using message filters with DreamHost spam filters

You can still use the message filters even if the domain is set up with MailChannels spam filters. Mail is filtered through the spam machines first, then routed to the regular incoming mail machines where your filters are applied.

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?