1<html> 2<head><title>Installation and Configuration</title> 3</head> 4<body> 5<h1>Installation</h1> 6<h2>Contents</h2> 7<ul> 8 <li><a href="#compile">Compiling and Installing Your Filter</a> 9 <li><a href="#config">Configuring Sendmail</a> 10</ul> 11 12<h2><a name="compile">Compiling and Installing Your Filter</A></h2> 13 14To compile a filter, modify the Makefile provided with the sample program, or: 15<ul> 16 <li>Put the include and Sendmail directories in your include path 17 (e.g. -I/path/to/include -I/path/to/sendmail). 18 19 <li>Make sure libmilter.a is in your library path, and link your 20 application with it (e.g. "-lmilter"). 21 22 <li>Compile with pthreads, either by using -pthread for gcc, or 23 linking with a pthreads support library (-lpthread). 24</ul> 25Your compile command line will look like 26<pre> 27cc -I/path/to/include -I/path/to/sendmail -c myfile.c 28</pre> 29and your linking command line will look something like 30<pre> 31cc -o myfilter [object-files] -L[library-location] -lmilter -pthread 32</pre> 33 34<H2><a name="config">Configuring Sendmail</A></H2> 35 36First, you must compile sendmail with MILTER defined. 37If you use a sendmail version older than 8.12 please see 38the instructions for your version. 39To do this, add the following lines to your build 40configuration file (devtools/Site/config.site.m4) 41<pre> 42APPENDDEF(`conf_sendmail_ENVDEF', `-DMILTER') 43</pre> 44 45then type <code>./Build -c</code> in your sendmail directory. 46 47<P> 48Next, you must add the desired filters to your sendmail configuration 49(.mc) file. 50Mail filters have three equates: 51The required <code>S=</code> equate specifies the socket where 52sendmail should look for the filter; The optional <code>F=</code> and 53<code>T=</code> equates specify flags and timeouts, respectively. All 54equates names, equate field names, and flag values are case sensitive. 55 56<P> 57The current flags (<code>F=</code>) are: 58<p> 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> 62</TR> 63<tr align="left" valign=top> 64<TD>R</TD> <TD>Reject connection if filter unavailable</TD> 65</TR> 66<tr align="left" valign=top> 67<TD>T</TD> <TD>Temporary fail connection if filter unavailable</TD> 68</TR> 69</TABLE> 70 71If a filter is unavailable or unresponsive and no flags have been 72specified, the MTA will continue normal handling of the current 73connection. The MTA will try to contact the filter again on each new 74connection. 75 76<P> 77There are three fields inside of the <code>T=</code> equate: S, R, and 78E. Note the separator between each is a ";" (semicolon), as "," 79(comma) already separates equates. The value of each field is a 80decimal number followed by a single letter designating the units ("s" 81for seconds, "m" for minutes). The fields have the following 82meanings: 83<p> 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> 87</TR> 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. 91 Default: 5m</TD> 92</TR> 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> 96</TR> 97<TR align="left" valign=top> 98<TD>R</TD> <TD>Timeout for reading reply from the filter. Default: 10s</TD> 99</TR> 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> 103</TR> 104</TABLE> 105 106<p> 107The following sendmail.mc example specifies three filters. The first 108two rendezvous on Unix-domain sockets in the /var/run directory; the 109third uses an IP socket on port 999. 110<pre> 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') 114 115 define(`confINPUT_MAIL_FILTERS', `filter2,filter1,filter3') 116<hr width="30%"> 117 m4 ../m4/cf.m4 myconfig.mc > myconfig.cf 118</pre> 119By default, the filters would be run in the order declared, 120i.e. "filter1, filter2, filter3"; however, since 121<code>confINPUT_MAIL_FILTERS</code> is defined, the filters will be 122run "filter2, filter1, filter3". Also note that a filter can be 123defined without adding it to the input filter list by using 124MAIL_FILTER() instead of INPUT_MAIL_FILTER(). 125 126<p> 127The above macros will result in the following lines being added to 128your .cf file: 129<PRE> 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 133 134 O InputMailFilters=filter2,filter1,filter3 135</PRE> 136<p> 137Finally, the sendmail macros accessible via <a 138href="smfi_getsymval.html">smfi_getsymval</a> can be configured by 139defining 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> 144</tr> 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> 155</table> 156For information about available macros and their meanings, please 157consult the sendmail documentation. 158<hr size="1"> 159<font size="-1"> 160Copyright (c) 2000-2003 Sendmail, Inc. and its suppliers. 161All rights reserved. 162<br> 163By using this file, you agree to the terms and conditions set 164forth in the LICENSE. 165</font> 166</body> </html> 167