4 {pmg} ships with a highly configurable mail filter. It’s an easy but
5 powerful way to define filter rules by user, domains, time frame,
6 content type and resulting action.
8 image::images/screenshot/pmg-gui-mail-filter-rules.png[]
10 Every rule has 5 categories ('FROM', 'TO', 'WHEN', 'WHAT' and
11 'ACTION'), and each category may contain several objects to match
16 Who is the sender or receiver of the e-mail? Those objects can be used
17 for the 'TO' and/or 'FROM' category.
20 Example: EMail-object - Who is the sender or receiver of the e-mail?
25 What is in the e-mail?
28 Example: Does the e-mail contain spam?
33 When is the e-mail received by {pmg}?
36 Example: Office Hours - Mail is received between 8:00 and 16:00.
41 Defines the final actions.
44 Example: Mark e-mail with “SPAM:” in the subject.
47 Rules are ordered by priority, so rules with higher priority are
48 executed first. It is also possible to set a processing direction:
50 'In':: Rule applies for all incoming e-mails
52 'Out':: Rule applies for all outgoing e-mails
54 'In & Out':: Rule applies for both directions
56 And you can also disable a rule completely, which is mostly useful for
57 testing and debugging. The 'Factory Defaults' button alows you to
58 reset the filter rules.
64 image::images/screenshot/pmg-gui-mail-filter-actions.png[]
66 Please note that some actions stops further rule precessing. We call
72 Accept mail for Delivery. This is a 'final' action.
78 Block mail. This is a 'final' action.
84 Move to quarantine (virus mails are moved to the “virus quarantine”,
85 other mails are moved to “spam quarantine”). This is also a 'final' action.
91 Send notifications. Please note that object configuration can use
92 xref:rule_system_macros[macros], so it is easy to include additional
93 information. For example, the default 'Notify Admin' object sends the
94 following information:
96 .Sample notification action body:
100 Receiver: __RECEIVERS__
103 Matching Rule: __RULE__
111 Notification can also include a copy of the original mail.
114 Blind Carbon Copy (BCC)
115 ~~~~~~~~~~~~~~~~~~~~~~~
117 The BCC object simply sends a copy to another target. It is possible to
118 send the original unmodified mail, or the processed result. Please
119 note that this can be quite different, i.e. when a previous rule
126 This object is able to add or modify mail header attributes. As notice above, you can use xref:rule_system_macros[macros], making this a very powerful object. For example, the 'Modify Spam Level' actions adds detailed infomation about detected Spam characteristics to the ` X-SPAM-LEVEL` header.
128 .'Modify Spam Level' Header Attribute
134 Another prominent example is the 'Modify Spam Subject' action. This
135 simply adds the 'SPAM:' prefix to the original mail subject:
137 .'Modify Spam Subject' Header Attribute
140 Value: SPAM: __SUBJECT__
147 Remove attachments can either remove all attachments, or only those
148 matched by the rules 'WHAT' object. You can also specify the
149 replacement text if you want.
161 image::images/screenshot/pmg-gui-mail-filter-who-objects.png[]
163 This type of objects can be used for the 'TO' and/or 'FROM' category,
164 and macth the sender or receiver of the e-mail. A single object can
165 combine multiple items, and the following item types are available:
169 Allows you to match a single mail address.
173 Only match the domain part of the mail address.
177 This one uses a regular expression to match the whole mail address.
179 IP Address or Network::
181 This can be used to match the senders IP address.
185 Test if the mail address belong to a specific LDAP user or group.
187 We have two important WHO objects called 'Blacklist' and
188 'Whitelist'. Those are used in the default ruleset to globally block
189 or allow specific senders.
195 image::images/screenshot/pmg-gui-mail-filter-what-objects.png[]
197 WHAT - objects are used to classify the mail content. A single object
198 can combine multiple items, and the following item types are
203 Matches if configured value if greater than the detected spam level.
207 Matches on infected mails.
211 Match specified mail header fields (eg. `Subject:`, `From:`, ...)
213 Content Type Filter::
215 Can be used to match specific content types.
219 Uses regular expressions to match attachment filenames.
223 Can be used to match specific content types inside archives.
229 image::images/screenshot/pmg-gui-mail-filter-when-objects.png[]
231 WHEN - objects are use to activate rules at specific daytimes. You can compose
232 them of one or more time-frame items.
234 The default ruleset defines 'Office Hours', but this is not used by
238 Using regular expressions
239 -------------------------
241 A regular expression is a string of characters which tells us which
242 string you are looking for. The following is a short introduction in
243 the syntax of regular expressions used by some objects. If you are
244 familiar with Perl, you already know the syntax.
246 Simple regular expressions
247 ~~~~~~~~~~~~~~~~~~~~~~~~~~
249 In its simplest form, a regular expression is just a word or phrase to
250 search for. `Mail` would match the string "Mail". The search is case
251 sensitive so "MAIL", "Mail", "mail" would not be matched.
256 Some characters have a special meaning. These characters are called
257 metacharacters. The Period (`.`) is a commonly used metacharacter. It
258 matches exactly one character, regardless of what the character is.
259 `e.mail` would match either "e-mail" or "e-mail" or "e2mail" but not
262 The question mark (`?`) indicates that the character immediately
263 preceding it either zero or one time. `e?mail` would match
264 either "email" or "mail" but not "e-mail".
266 Another metacharacter is the star (`*`). This indicates that the
267 character immediately to its left may repeated any number of times,
268 including zero. `e*mail` would match either "email" or "mail" or
271 The plus (`+`) metacharacter does the same as the star (*) excluding
272 zero. So `e+mail` does not match "mail".
274 Metacharacters may be combined. A common combination includes the
275 period and star metacharacters (`.*`), with the star immediately following
276 the period. This is used to match an arbitrary string of any length,
277 including the null string. For example: `.*company.*` matches
278 "company@domain.com" or "company@domain.co.uk" or
279 "department.company@domain.com".
281 The book xref:Friedl97[] provides a more comprehensive introduction.