Differences between version 8 and predecessor to the previous major change of EximFilter.
Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History
Newer page: | version 8 | Last edited on Monday, December 6, 2004 10:36:56 am | by AristotlePagaltzis | Revert |
Older page: | version 2 | Last edited on Wednesday, September 24, 2003 8:29:53 am | by JohnMcPherson | Revert |
@@ -1,29 +1,116 @@
-If your .forward file starts
with "
# Exim filter"
, then the [Exim] mail program
can do some processing of your incoming email
.
+If you start
your <tt>
.forward</tt>
file with __<tt>
# Exim filter</tt>__
, then the [Exim] [MTA]
can do some processing of your incoming [Email]
. Documentation about this is available at:
-If you have exim installed, you can probably find comprehensive documentation on this in
-
/usr/share/doc/exim/filter.txt{,.gz}
-otherwise have a look online at
www.exim.org/exim-html-3.30/doc/html/filter.html or
www.exim.org/exim-html-4.00/doc/html/filter.html depending on which version of exim you have installed.
+* <tt>
/usr/share/doc/exim/filter.txt{,.gz}</tt>
+* [Exim 3.3 Filter Specification | http://
www.exim.org/exim-html-3.30/doc/html/filter.html]
+ / [Exim 4.0 Filter Specification | http://
www.exim.org/exim-html-4.00/doc/html/filter.html]
-Here is
a simple example:
+!!! Testing
a filter
- # Exim
filter - do not edit this line!
- # only works for
exim... others will treat
it as a plain .forward file...
+You can create a
filter with any filename (such as $HOME/
exim.filter) and then
+test
it with
- # if this filter generates an error, then deliver to original address
- # as per usual
- if error_message then finish endif
+<pre>
+/usr/sbin/exim -bf $HOME/exim.filter -f ''fromaddress'' -bfl ''username'' -bfs ''+suffix''
+</pre>
- # I have mail forwarded to me from
an account at another machine.
- # it currently only gets spam
, so automatically save to somewhere else
.
- # This match is a regular expression
, hence need
to double escape the "."
-
if $header_received: contains remotehost\\
.co\\
.nz
- and $header_from: does not contain remotehost\\.co\\.nz
- then
- save $home/Mail/remotehostspam 0600
- seen finish
- endif
+This will read
an [Email] from stdin(3) and tell you which tests matched
, and what would have happened if that message was actually being delivered
. You can change ''fromaddress''
, ''username'', and ''suffix''
to test specific rules, and you can omit <tt>-bfl</tt>
if ''username'' is your own username
. If your filter is simple enough that it doesn't use any message headers you can supply an empty message
.
-
# default action - get exim to deliver as if this forward file wasn't here
-
# change this to whatever address this server is accepting your mail for
-
deliver thisemailaddress@verisign.com
- finish
+!!! Examples
+
+!! A simple example
+
+<verbatim>
+# Exim filter - do not edit this line!
+# only works for exim... others will treat it as a plain .forward file...
+
+# if this filter generates an error, then deliver to original address
+# as per usual
+if error_message then finish endif
+
+# I have mail forwarded to me from an account at another machine.
+# it currently only gets spam, so automatically save to somewhere else.
+# This match is a regular expression, hence need to double escape the "."
+if $header_received: contains remotehost\\.co\\.nz
+ and $header_from: does not contain remotehost\\.co\\.nz
+then
+ save $home/Mail/remotehostspam 0600 # 0600 is the file mode (as in chmod)
+ seen finish
+endif
+
+
# default action - get exim to deliver as if this forward file wasn't here
+# change this to whatever address this server is accepting your mail for
+deliver thisemailaddress@verisign.com
+finish
+</verbatim>
+
+!! For the [WLUG] MailServer
+
+Since [Exim] on the MailServer supports a suffix (eg any mail to <tt>username+suffix@example.com</tt> gets delivered to <tt>username</tt>, regardless the <tt>suffix</tt>), you can filter incoming messages based on this.
+
+Probably the only thing to be aware of is that if you use the <tt>save</tt> command, it saves to the named MailBox using [MBox] format rather than MailDir.
+
+<verbatim>
+# Exim filter - do not edit this line!
+
+# if this filter generates an error, then exim will act as if there was
+# no filter file (as per usual)
+if error_message then finish endif
+
+# the 'testprint' command will print out its argument if you are running
+# exim in test mode, and will do nothing if run 'live'
+testprint "suffix is $local_part_suffix, subject is $h_subject"
+
+# discard any mail that has "+nospam" as a suffix...
+if ${local_part_suffix} is "+nospam" then
+ seen # tell exim that we've delivered it (even though we haven't really)
+ finish # don't try any more tests or deliveries
+endif
+
+
+# any mail with the "+foo" suffix will have a copy sent elsewhere,
+# AS WELL AS delivered as if this rule wasn't here
+if ${local_part_suffix} is "+foo" then
+ unseen # pretend that we haven't delivered it, when we really have
+ deliver otheraddress@example.com
+endif
+
+
+# any mail with a suffix matching this regular expression will be saved into
+# the "bugs" directory as maildir (ie one file per message).
+# Note that:
+# 1) \ and $ in a regular expression need to be \ escaped,
+# 2) you need to use " and double-escaping if your pattern has whitespace, and
+# 3) exim uses perl-compatible regular expressions
+# (This matches if the suffix contains "bugs" or contains 3 or more digits in a row
+if ${local_part_suffix} matches bugs|\\d{3,} then
+ # 0600 is the octal file permissions
+ save $home/Maildir/bugs/new/$message_id.$domain 0600
+ finish # finish processing this filter file
+endif
+# Note! if you want mail applications to correctly recognise a folder as maildir
+# format, make sure that it exists and has 3 subdirectories named
+# "new", "tmp", and "cur". Otherwise you risk losing mail...
+
+# if a message has a particular sender address (either From or Sender), save it
+# into a particular file (as mbox). Note that this variable will be empty for
+# automatically generated messages such as bounces
+if $sender_address matches "@domainz\\\\.co\\\\.nz\\$" then
+ save $home/mail/domainnames 0600
+endif
+
+
+# ignore any mail that was sent from this network
+if $h_received: contains static.tfn.net.tw then
+ # "seen finish" tells exim that we have processed this message
+ seen finish
+endif
+
+
+# default action, if this filter hasn't yet caused a 'significant delivery'
+# for the incoming message
+
+if not delivered then
+ deliver ${local_part}
+endif
+
+</verbatim>