]> git.proxmox.com Git - pmg-docs.git/blame_incremental - pmg-mail-filter.adoc
backup: shortly document #3146 and #3154
[pmg-docs.git] / pmg-mail-filter.adoc
... / ...
CommitLineData
1[[chapter_mailfilter]]
2Rule-Based Mail Filter
3======================
4
5{pmg} ships with a highly configurable mail filter. It’s an easy but
6powerful way to define filter rules by user, domains, time frame,
7content type and resulting action.
8
9[thumbnail="pmg-gui-mail-filter-rules.png", big=1]
10
11Every rule has 5 categories ('FROM', 'TO', 'WHEN', 'WHAT' and
12'ACTION'), and each category may contain several objects to match
13certain criteria:
14
15'Who' - objects::
16
17Who is the sender or recipient of the email? Those objects can be used
18for the 'TO' and/or 'FROM' category.
19+
20====
21Example: EMail-object - Who is the sender or recipient of the email?
22====
23
24'What' - objects::
25
26What is in the email?
27+
28====
29Example: Does the email contain spam?
30====
31
32'When' - objects::
33
34When is the email received by {pmg}?
35+
36====
37Example: Office Hours - Mail is received between 8:00 and 16:00.
38====
39
40'Action' - objects::
41
42Defines the final actions.
43+
44====
45Example: Mark email with “SPAM:” in the subject.
46====
47
48Rules are ordered by priority, so rules with higher priority are
49executed first. It is also possible to set a processing direction:
50
51'In':: Rule applies for all incoming emails
52
53'Out':: Rule applies for all outgoing emails
54
55'In & Out':: Rule applies for both directions
56
57And you can also disable a rule completely, which is mostly useful for
58testing and debugging. The 'Factory Defaults' button alows you to
59reset the filter rules.
60
61
62[[pmg_mailfilter_action]]
63'Action' - objects
64------------------
65
66[thumbnail="pmg-gui-mail-filter-actions.png", big=1]
67
68Please note that some actions stop further rule processing. We call
69such actions 'final'.
70
71Accept
72~~~~~~
73
74Accept mail for Delivery. This is a 'final' action.
75
76
77Block
78~~~~~
79
80Block mail. This is a 'final' action.
81
82
83Quarantine
84~~~~~~~~~~
85
86Move to quarantine (virus mails are moved to the “virus quarantine”,
87other mails are moved to “spam quarantine”). This is also a 'final' action.
88
89
90Notification
91~~~~~~~~~~~~
92
93Send notifications. Please note that object configuration can use
94xref:rule_system_macros[macros], so it is easy to include additional
95information. For example, the default 'Notify Admin' object sends the
96following information:
97
98.Sample notification action body:
99----
100Proxmox Notification:
101Sender: __SENDER__
102Receiver: __RECEIVERS__
103Targets: __TARGETS__
104Subject: __SUBJECT__
105Matching Rule: __RULE__
106
107__RULE_INFO__
108
109__VIRUS_INFO__
110__SPAM_INFO__
111----
112
113Notification can also include a copy of the original mail.
114
115
116Blind Carbon Copy (BCC)
117~~~~~~~~~~~~~~~~~~~~~~~
118
119The BCC object simply sends a copy to another target. It is possible to
120send the original unmodified mail, or the processed result. Please
121note that this can be quite different, i.e. when a previous rule
122removed attachments.
123
124
125Header Attributes
126~~~~~~~~~~~~~~~~~
127
128This object is able to add or modify mail header attributes. As with notifications above, you can use xref:rule_system_macros[macros], making this a very powerful object. For example, the 'Modify Spam Level' actions adds detailed information about detected Spam characteristics to the `X-SPAM-LEVEL` header.
129
130.'Modify Spam Level' Header Attribute
131----
132Field: X-SPAM-LEVEL
133Value: __SPAM_INFO__
134----
135
136Another prominent example is the 'Modify Spam Subject' action. This
137simply adds the 'SPAM:' prefix to the original mail subject:
138
139.'Modify Spam Subject' Header Attribute
140----
141Field: subject
142Value: SPAM: __SUBJECT__
143----
144
145
146Remove attachments
147~~~~~~~~~~~~~~~~~~
148
149Remove attachments can either remove all attachments, or only those
150matched by the rules 'What' - object. You can also specify the
151replacement text if you want.
152
153You can optionally move those mails into the attachment quarantine, where
154the original mail with all attachments will be stored. The mail with the
155attachments removed will continue in the rule system.
156
157NOTE: The Attachment Quarantine Lifetime is the same as for the Spam Quarantine.
158
159
160Disclaimer
161~~~~~~~~~~
162
163Add a Disclaimer.
164
165The disclaimer can contain HTML markup. It will be added to the first
166`text/html` and `text/plain` part of an email. A disclaimer only gets added if
167its text can be encoded in the mail's character encoding.
168
169
170[[pmg_mailfilter_who]]
171'Who' - objects
172---------------
173
174[thumbnail="pmg-gui-mail-filter-who-objects.png", big=1]
175
176This type of objects can be used for the 'TO' and/or 'FROM' category,
177and match the sender or recipient of the email. A single object can
178combine multiple items, and the following item types are available:
179
180EMail::
181
182Allows you to match a single mail address.
183
184Domain::
185
186Only match the domain part of the mail address.
187
188Regular Expression::
189
190This one uses a regular expression to match the whole mail address.
191
192IP Address or Network::
193
194This can be used to match the senders IP address.
195
196LDAP User or Group::
197
198Test if the mail address belongs to a specific LDAP user or group.
199
200We have two important 'Who' - objects called 'Blacklist' and
201'Whitelist'. These are used in the default ruleset to globally block
202or allow specific senders.
203
204
205[[pmg_mailfilter_what]]
206'What' - objects
207----------------
208
209[thumbnail="pmg-gui-mail-filter-what-objects.png", big=1]
210
211'What' - objects are used to classify the mail content. A single
212object can combine multiple items, and the following item types are
213available:
214
215Spam Filter::
216
217Matches if detected spam level is equal or greater than the configured value.
218
219Virus Filter::
220
221Matches on infected mails.
222
223Match Field::
224
225Match specified mail header fields (eg. `Subject:`, `From:`, ...)
226
227Content Type Filter::
228
229Can be used to match specific content types.
230
231Match Filename::
232
233Uses regular expressions to match attachment filenames.
234
235Archive Filter::
236
237Can be used to match specific content types inside archives.
238This also matches the content-types of all regular (non-archived) attachments.
239
240Match Archive Filename::
241
242Uses regular expressions to match attachment filenames inside archives.
243This also matches the filenames for all regular (non-archived) attachments.
244
245
246[[pmg_mailfilter_when]]
247'When' - objects
248----------------
249
250[thumbnail="pmg-gui-mail-filter-when-objects.png", big=1]
251
252'When' - objects are use to activate rules at specific daytimes. You
253can compose them of one or more time frame items.
254
255The default ruleset defines 'Office Hours', but this is not used by
256the default rules.
257
258
259[[pmg_mailfilter_regex]]
260Using regular expressions
261-------------------------
262
263A regular expression is a string of characters which tells us which
264string you are looking for. The following is a short introduction in
265the syntax of regular expressions used by some objects. If you are
266familiar with Perl, you already know the syntax.
267
268Simple regular expressions
269~~~~~~~~~~~~~~~~~~~~~~~~~~
270
271In its simplest form, a regular expression is just a word or phrase to
272search for. `Mail` would match the string "Mail". The search is case
273sensitive so "MAIL", "Mail", "mail" would not be matched.
274
275Metacharacters
276~~~~~~~~~~~~~~
277
278Some characters have a special meaning. These characters are called
279metacharacters. The Period (`.`) is a commonly used metacharacter. It
280matches exactly one character, regardless of what the character is.
281`e.mail` would match either "e-mail" or "e2mail" but not
282"e-some-mail" or "email".
283
284The question mark (`?`) indicates that the character immediately
285preceding it shows up either zero or one time. `e?mail` would match
286either "email" or "mail" but not "e-mail".
287
288Another metacharacter is the star (`*`). This indicates that the
289character immediately preceding it may be repeated any number of times,
290including zero. `e*mail` would match either "email" or "mail" or
291"eeemail".
292
293The plus (`+`) metacharacter does the same as the star (*) excluding
294zero. So `e+mail` does not match "mail".
295
296Metacharacters may be combined. A common combination includes the
297period and star metacharacters (`.*`), with the star immediately following
298the period. This is used to match an arbitrary string of any length,
299including the null string. For example: `.*company.*` matches
300"company@domain.com" or "company@domain.co.uk" or
301"department.company@domain.com".
302
303The book xref:Friedl97[] provides a more comprehensive introduction.