Custom filters — Explanation of the message filter fields

Overview

The following is a list of available fields you can add on the Message Filters page in your panel.

View the How do I enable message filters on my email address article for further details.

The following should be taken into consideration when creating filters:

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

How 'execute and stop' functions

The 'execute and stop' rule only applies to a rule that performs a delivery action such as moving the email to a folder.

If the rule is set to only add text to the HEADER or Subject, 'execute and stop' will not apply. In this case, the filter will continue to the next rule until it runs a rule with a delivery action. The following examples explain this further.

Rule Result Explanation

First, add FILTERED to the subject of emails with testing in the subject and then stop.


Finally, move emails with example.com in the from to filterfolder and then 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.

First, add FILTERED to the subject of emails with testing in the subject and then stop.


Then, move emails with example.com in the from to filterfolder and then stop.


Finally, add the header Test-Header: FILTERED to emails with *example.com in the headers and then 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.

 

The final rule is not applied.

 

 

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

 

Since the second rule performed a delivery action, the filter was executed and stopped.

 

The final rule was not executed since the second rule performed the delivery action.

 

List of fields to add to your custom filter


Field Explanation Example

Subject

Looks in the Subject line of the email. It looks everywhere in the subject line, and can match part or all of the Subject.

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

From

Looks in the From line of the email, checking for who sent the email. It looks everywhere in the From line, and can match part or all of the From line.

match bob in From: bob@example.com

match Jones in From: Bob Jones <bob@example.com>

To

Looks in the To line of the email, checking for whom the email was sent to. It starts searching directly after To. Use * before your term to match any part of the name or email address anywhere in the line.

Tip: Combine this rule with using + for slightly customized email addresses for easy sorting of emails from websites. Give Amazon your email address as you+amazon@example.com and then you can easily filter those emails.

match George in To: George of the Jungle <george@example.com>

match books in To: me+books@example.com

CC

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

Headers

Looks at the beginning of every line in the email header. Intended for use when matching header lines, such as X-Spam: Yes. Note that this only checks the headers. It does not check the message body.

Tip: use * to match anywhere in the line, not just the beginning.

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

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

Reply-To

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

Body

Looks in the message body of the email and does not look in the headers. N/A

 

Explanation of the 'Do this' action option fields


Field Explanation Example

Move it to folder

Puts the email in the specified folder. This is possibly the most useful action, but there are a few caveats/restrictions:

Folder names are cAsE sEnSiTiVe! Double-check your folder name's spelling and Shift key usage.

The filters cannot use folder names that have spaces in the name. Subfolders are okay, but must be specified with the parent folder and a period (e.g. ParentFolder.SubFolder). Folder names can only contain only letters, numbers, underscores, dots, and dashes. (But no leading dots, trailing dots, or double dots!)

N/A

Add this to the subject

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

Subject: Test Email

becomes

Subject: ADDED_TEXT Test Email

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 all the headers. N/A

Forward to shell account

Forward the email to the /Maildir directory of a shell user. This is the same as forwarding to shell_user@servername.dreamhost.com. You can control what happens to the email received by the shell user by creating a .forward.postfix file in your user's home directory.

Permissions

The .forward.postfix file can have 644 permissions.

The file you want to run must have 755 permissions.

These examples show what to put into the .forward.postfix file in order to run a file when the email is received. Make sure to change username to your Shell user.

To run a bash script: 

"| /home/username/myscript.sh"

To run a PHP file script:

"| /usr/local/php82/bin/php /home/username/myscript.php"

Delete it

The email is not put in the Trash folder and is completely erased. N/A

Doing more than one action

Each individual message filter can check for multiple things but can only perform a single action. You can use "execute and continue" to have multiple actions done on a single email. When a filter has "execute and continue" the action from the matching filter is taken, and then the next filter is checked and filtering continues. Normally, filters are made with "execute and stop" and the first rule that matches is the only action taken, and no more filters are checked.

Here's an example set of filters that check for spam and also sort mail into folders:

  • add POSSIBLE SPAM to the subject of emails for any of the following:
-contains viagra in the Subject
-contains diet in the Subject
-contains monkey in the Subject
and then continue
  • move emails to Amazon with Amazon in the Subject
and then stop.
  • move emails to Twitter with twitter.com in the From
and then stop.

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 gets routed to the regular incoming mail machines where your filters are then applied.

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?