File: filter_3.html

package info (click to toggle)
exim-html 3.20-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge, woody
  • size: 2,868 kB
  • ctags: 4,188
  • sloc: makefile: 40; sh: 19
file content (126 lines) | stat: -rw-r--r-- 5,243 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<HTML>
<HEAD>
<!-- This HTML file has been created by texi2html 1.52
     from filter on 25 November 2000 -->

<TITLE>Exim Filter Specification - Testing a new filter file</TITLE>
</HEAD>
<body bgcolor="#FFFFFF" text="#00005A" link="#FF6600" alink="#FF9933" vlink="#990000">
Go to the <A HREF="filter_1.html">first</A>, <A HREF="filter_2.html">previous</A>, <A HREF="filter_4.html">next</A>, <A HREF="filter_34.html">last</A> section, <A HREF="filter_toc.html">table of contents</A>.
<P><HR><P>


<H2><A NAME="SEC3" HREF="filter_toc.html#TOC3">Testing a new filter file</A></H2>

<P>
Filter files, especially the more complicated ones, should always be tested, as
it is easy to make mistakes. Exim provides a facility for preliminary testing
of a filter file before installing it. This tests the syntax of the file and
its basic operation, and can also be used with ordinary <TT>`.forward'</TT> files.

</P>
<P>
Because a filter can do tests on the content of messages, a test message is
required. Suppose you have a new filter file called <TT>`new-filter'</TT> and a test
message called <TT>`test-message'</TT>. Assuming that Exim is installed with the
conventional path name <TT>`/usr/lib/sendmail'</TT> (some operating systems use
<TT>`/usr/sbin/sendmail'</TT>), the following command can be used:

<PRE>
/usr/lib/sendmail -bf new-filter &#60;test-message
</PRE>

<P>
The -<EM>bf</EM> option tells Exim that the following item on the command line is the
name of a filter file which is to be tested.
<font color=green>
There is also a -<EM>bF</EM> option, which is similar, but which is used for testing
system filter files, as opposed to user filter files, and which is therefore of
use only to the system administrator.
</font>

</P>
<P>
The test message is supplied on the standard input. If there are no
message-dependent tests in the filter, then an empty file can be used. A
supplied message must start with header lines or the `From' message separator
line which is found in many multi-message folder files. Note that blank lines
at the start terminate the header lines. A warning is given if no headers are
read.

</P>
<P>
The result of running this command, provided no errors are detected in the
filter file, is a list of the actions that Exim would try to take if presented
with the message for real. For example, the output

<PRE>
Deliver message to: gulliver@lilliput.fict.example
Save message to: /home/lemuel/mail/archive
</PRE>

<P>
means that one copy of the message would be sent to
<EM>gulliver@lilliput.fict.example</EM>, and another would be added to the file
<TT>`/home/lemuel/mail/archive'</TT>, if all went well.

</P>
<P>
The actions themselves are not attempted while testing a filter file in this
way; there is no check, for example, that any forwarding addresses are valid.
If you want to know why a particular action is being taken, add the -<EM>v</EM> option
to the command. This causes Exim to output the results of any conditional tests
and to indent its output according to the depth if nesting of <EM>if</EM> commands.
Further additional output from a filter test can be generated by the
<EM>testprint</EM> command, which is described below.

</P>
<P>
When Exim is outputting a list of the actions it would take, if any text
strings are included in the output, non-printing characters therein are
converted to escape sequences. In particular, if any text string contains a
newline character, this is shown as `\n' in the testing output.

</P>
<P>
When testing a filter in this way, Exim makes up an `envelope' for the message.
The recipient is by default the user running the command, and so is the sender,
but the command can be run with the -<EM>f</EM> option to supply a different sender.
For example,

<PRE>
/usr/lib/sendmail -bf new-filter -f islington@neverwhere &#60;test-message
</PRE>

<P>
Alternatively, if the -<EM>f</EM> option is not used, but the first line of the
supplied message is a `From' separator from a message folder file (not the same
thing as a <TT>`From:'</TT> header line), the sender is taken from there. If -<EM>f</EM> is
present, the contents of any `From' line are ignored.

</P>
<P>
The `return path' is the same as the envelope sender, unless the message
contains a <TT>`Return-path:'</TT> header, in which case it is taken from there. You
need not worry about any of this unless you want to test out features of a
filter file that rely on the sender address or the return path.

</P>
<P>
It is possible to change the envelope recipient by specifying further options.
The -<EM>bfd</EM> option changes the domain of the recipient address, while the
-<EM>bfl</EM>
option changes the `local part', that is, the part before the @ sign. An
adviser could make use of these to test someone else's filter file.

</P>
<P>
The -<EM>bfp</EM> and -<EM>bfs</EM> options specify the prefix or suffix for the local part.
These are relevant only when support for multiple personal mailboxes is
implemented; see the description in section 26 below.

</P>
<P><HR><P>
Go to the <A HREF="filter_1.html">first</A>, <A HREF="filter_2.html">previous</A>, <A HREF="filter_4.html">next</A>, <A HREF="filter_34.html">last</A> section, <A HREF="filter_toc.html">table of contents</A>.
</BODY>
</HTML>