2 <head><title>Installation and Configuration</title>
8 <li><a href="#compile">Compiling and Installing Your Filter</a>
9 <li><a href="#config">Configuring Sendmail</a>
12 <h2><a name="compile">Compiling and Installing Your Filter</A></h2>
14 To compile a filter, modify the Makefile provided with the sample program, or:
16 <li>Put the include and Sendmail directories in your include path
17 (e.g. -I/path/to/include -I/path/to/sendmail).
19 <li>Make sure libmilter.a is in your library path, and link your
20 application with it (e.g. "-lmilter").
22 <li>Compile with pthreads, either by using -pthread for gcc, or
23 linking with a pthreads support library (-lpthread).
25 Your compile command line will look like
27 cc -I/path/to/include -I/path/to/sendmail -c myfile.c
29 and your linking command line will look something like
31 cc -o myfilter [object-files] -L[library-location] -lmilter -pthread
34 <H2><a name="config">Configuring Sendmail</A></H2>
36 First, you must compile sendmail with MILTER defined.
37 If you use a sendmail version older than 8.12 please see
38 the instructions for your version.
39 To do this, add the following lines to your build
40 configuration file (devtools/Site/config.site.m4)
42 APPENDDEF(`conf_sendmail_ENVDEF', `-DMILTER')
45 then type <code>./Build -c</code> in your sendmail directory.
48 Next, you must add the desired filters to your sendmail configuration
50 Mail filters have three equates:
51 The required <code>S=</code> equate specifies the socket where
52 sendmail should look for the filter; The optional <code>F=</code> and
53 <code>T=</code> equates specify flags and timeouts, respectively. All
54 equates names, equate field names, and flag values are case sensitive.
57 The current flags (<code>F=</code>) are:
59 <table cellspacing="1" cellpadding=4 border=1>
60 <tr bgcolor="#dddddd" align=left valign=top>
61 <th>Flag</TH> <th align="center">Meaning</TH>
63 <tr align="left" valign=top>
64 <TD>R</TD> <TD>Reject connection if filter unavailable</TD>
66 <tr align="left" valign=top>
67 <TD>T</TD> <TD>Temporary fail connection if filter unavailable</TD>
71 If a filter is unavailable or unresponsive and no flags have been
72 specified, the MTA will continue normal handling of the current
73 connection. The MTA will try to contact the filter again on each new
77 There are three fields inside of the <code>T=</code> equate: S, R, and
78 E. Note the separator between each is a ";" (semicolon), as ","
79 (comma) already separates equates. The value of each field is a
80 decimal number followed by a single letter designating the units ("s"
81 for seconds, "m" for minutes). The fields have the following
84 <TABLE cellspacing="1" cellpadding=4 border=1>
85 <TR bgcolor="#dddddd" align=left valign=top>
86 <TH>Flag</TH> <TH align="center">Meaning</TH>
88 <TR align="left" valign=top>
89 <TD>C</TD> <TD>Timeout for connecting to a filter. If set to 0, the
90 system's <CODE>connect()</CODE> timeout will be used.
93 <TR align="left" valign=top>
94 <TD>S</TD> <TD>Timeout for sending information from the MTA to a
95 filter. Default: 10s</TD>
97 <TR align="left" valign=top>
98 <TD>R</TD> <TD>Timeout for reading reply from the filter. Default: 10s</TD>
100 <TR align="left" valign=top>
101 <TD>E</TD> <TD>Overall timeout between sending end-of-message to
102 filter and waiting for the final acknowledgment. Default: 5m</TD>
107 The following sendmail.mc example specifies three filters. The first
108 two rendezvous on Unix-domain sockets in the /var/run directory; the
109 third uses an IP socket on port 999.
111 INPUT_MAIL_FILTER(`filter1', `S=unix:/var/run/f1.sock, F=R')
112 INPUT_MAIL_FILTER(`filter2', `S=unix:/var/run/f2.sock, F=T, T=S:1s;R:1s;E:5m')
113 INPUT_MAIL_FILTER(`filter3', `S=inet:999@localhost, T=C:2m')
115 define(`confINPUT_MAIL_FILTERS', `filter2,filter1,filter3')
117 m4 ../m4/cf.m4 myconfig.mc > myconfig.cf
119 By default, the filters would be run in the order declared,
120 i.e. "filter1, filter2, filter3"; however, since
121 <code>confINPUT_MAIL_FILTERS</code> is defined, the filters will be
122 run "filter2, filter1, filter3". Also note that a filter can be
123 defined without adding it to the input filter list by using
124 MAIL_FILTER() instead of INPUT_MAIL_FILTER().
127 The above macros will result in the following lines being added to
130 Xfilter1, S=unix:/var/run/f1.sock, F=R
131 Xfilter2, S=unix:/var/run/f2.sock, F=T, T=S:1s;R:1s;E:5m
132 Xfilter3, S=inet:999@localhost, T=C:2m
134 O InputMailFilters=filter2,filter1,filter3
137 Finally, the sendmail macros accessible via <a
138 href="smfi_getsymval.html">smfi_getsymval</a> can be configured by
139 defining the following m4 variables (or cf options):
140 <table cellspacing="1" cellpadding=4 border=1>
141 <tr bgcolor="#dddddd" align=left valign=top>
142 <th align="center">In .mc file</th> <th align="center">In .cf file</TH>
143 <th align="center">Default Value</th>
145 <tr><td>confMILTER_MACROS_CONNECT</td><td>Milter.macros.connect</td>
146 <td><code>j, _, {daemon_name}, {if_name}, {if_addr}</code></td></tr>
147 <tr><td>confMILTER_MACROS_HELO</td><td>Milter.macros.helo</td>
148 <td><code>{tls_version}, {cipher}, {cipher_bits}, {cert_subject},
149 {cert_issuer}</code></td></tr>
150 <tr><td>confMILTER_MACROS_ENVFROM</td><td>Milter.macros.envfrom</td>
151 <td><code>i, {auth_type}, {auth_authen}, {auth_ssf}, {auth_author},
152 {mail_mailer}, {mail_host}, {mail_addr}</code></td></tr>
153 <tr><td>confMILTER_MACROS_ENVRCPT</td><td>Milter.macros.envrcpt</td>
154 <td><code>{rcpt_mailer}, {rcpt_host}, {rcpt_addr}</code></td></tr>
156 For information about available macros and their meanings, please
157 consult the sendmail documentation.
160 Copyright (c) 2000-2003 Sendmail, Inc. and its suppliers.
163 By using this file, you agree to the terms and conditions set
164 forth in the LICENSE.