Message Filters

From DreamHost
(Redirected from Procmail)
Jump to: navigation, search

Overview

Message filters are special rules you can create which automatically perform actions on incoming email. This is a simple way to make incoming email easier to sort and categorize. For example, you could label all email messages from your boss as “Important”. The filter could then add the word IMPORTANT to the subject of emails with boss@example.com in the from field.

Filters can be created only for fully-hosted email addresses. Another option is to enable anti-spam filters in the panel. If you do so, the anti-spam filters are applied first, then your custom message filters are applied. You can also add filters on your specific mail client such as Thunderbird, Outlook, or Gmail.

This article decribes how to add custom filters in your DreamHost panel.

Adding message filters

Enabling message filters in the panel

You can create a custom filter in your panel, and a list of all your fully-hosted email addresses will be listed on your Message Filters page.

  1. Navigate to (Panel > ‘Mail’ > ‘Message Filters’).
  2. To the right of an address, click the Edit button to open the filter page.
    01 Message Filters.fw.png
  3. If you have not added filters yet, click the Add New Filter button.
    The add new filter page opens where you can set up a filter:
    02 Message Filters.fw.png
  4. When finished creating your rule, click the Add Filter button at the bottom.

Adding a filter using the mailboxes subdomain

You can also use the mailboxes.example.com subdomain to create a filter:

  1. Log into your mailbox manager at mailboxes.example.com (change examle.com to your domain).
    03 Message Filters.fw.png
  2. Click the link under ‘Email Filters’.
    04 Message Filters.fw.png
  3. Enter your new filter settings and click Add Filter.

Adding a filter using the DreamHost API

Another approach to setting Message Filters is through the Mail API (requires an API key generated in the panel's Web Panel API page).

Use mail-list_filters to list all filters on all mail accounts, and use mail-add_filter or mail-remove_filter to add or remove filters.

Explanation of the filter fields

Note2 icon.png Notes: 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.


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 the name or email address anywhere in the line.
  • match "George" in "To: George of the Jungle <george@example.com>"

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@yourdomain.com and then you can easily filter those emails.

  • 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. Intended for use when matching header lines, such as "X-Spam: Yes". Note that this checks the entire email – the message body and the headers.
  • match "X-Spam: Yes" in the email's headers

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

  • match ".*bananas" to match "bananas" anywhere in any line of the email

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:

  • The folder must already exist – the filter cannot make the folder for you. If you enter a folder name that does not exist, the emails will be deleted instead of moved.
  • 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 '.', like 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 it to email address

What it says. The email address to forward the email to can be any address, hosted at DreamHost or anywhere else. N/A

Forward to shell account

Forward the email to the Maildir of a shell user. This is the same as forwarding to an email address and specifying shell_user@server_name.dreamhost.com. N/A

Delete it

What it says. 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.

A note on the forwarding rule

Forwarding will act very differently depending on the final ‘execute and stop’ or ‘execute and continue’ rule.

For example, a single filter set to:

  • forward and continue – forwards the email, after which a copy is also placed in your inbox.
  • forward and stop – ends the filter chain before it reaches the end, so no message would be placed in your inbox.

Using message filters with the Junk Mail filters

As noted earlier, you can still use the message filters even if the domain is set up with the anti-spam junk mail service. Mail will come in through the junk mail filtering machines first, then gets routed to the regular incoming mail machines where your filters are then applied. Emails that are quarantined go there before your keyword filters are applied.