Recipe 6.12 Using MILTER

Problem

You have installed an external mail filtering tool that complies with the Sendmail Mail Filter API . You now need to configure sendmail to make use of that external mail filter.

Solution

Run the sendmail -d0.1 command. The "Compiled with:" line output by the command should contain MILTER . If it does not, add MILTER support by adding the following line to the site.config.m4 file:

 APPENDDEF(`confENVDEF', `-DMILTER') 

Recompile sendmail as described in Chapter 1, in Recipe 1.3 through Recipe 1.7.

Add an INPUT_MAIL_FILTER macro to the sendmail configuration that identifies the external mail filter. At a minimum, the INPUT_MAIL_FILTER macro must define the internal name of the filter and the socket specification required by the filter. Refer to the documentation that comes with the MILTER to find the recommended settings. As an example, the following line could be added to the sendmail configuration to use the vbsfilter MILTER available from http://aeschi.ch.eu.org/milter/:

 INPUT_MAIL_FILTER(`sample', `S=local:/var/run/vbsfilter.sock') 

Rebuild the sendmail.cf file, copy the new sendmail.cf file to /etc/mail , and restart sendmail, as described in Recipe 1.8.

Discussion

Before an external program can be used by sendmail, it must be located, downloaded, installed, and properly configured. The introduction to this chapter points to a few web sites where you can start your search for useful MILTERs. Because of the complexity of filtering for spam and scanning for viruses, and because of the constantly changing nature of the threats, configuring a MILTER can be much more challenging than configuring sendmail to use the MILTER. Read the MILTER documentation carefully so that you understand exactly what INPUT_MAIL_FILTER arguments are needed for sendmail to interface with the external filter.

The sample sendmail configuration in the Solution section uses an INPUT_MAIL_FILTER macro recommended by the documentation for the mail filter vbsfilter . The vbsfilter program identifies various dangerous executable attachments and renames them with the .txt extension so that they will not be automatically executed by the end user 's system. The socket defined in the INPUT_MAIL_FILTER macro must match the socket used by the MILTER. For vbsfilter , this is accomplished by running the MILTER with a -p argument that tells vbsfilter which socket to use. Given the INPUT_MAIL_FILTER macro shown in the Solution section, vbsfilter would be started with the following command:

 #  vbsfilter -p S=local:/var/run/vbsfilter.sock  

The vbsfilter is a good one to start with because it does not require much configuration. So is the sample MILTER provided in the libmilter/README file that comes with the sendmail distribution. The sample mail filter doesn't do any useful filtering, but it is easy to test and useful for determining that your sendmail system is properly configured and capable of interfacing with an external filter. Many filters are so complex that debugging the MILTER at the same time you are debugging sendmail can be overwhelming. Use a simple filter to debug sendmail before interfacing it to a complex filter.

See Also

Introduction to this chapter provides more information about MILTERs. The sendmail book covers MILTER in Section 7.6. The libmilter/README file also covers this topic, as do the files in libmilter/docs .



Sendmail Cookbook
sendmail Cookbook
ISBN: 0596004710
EAN: 2147483647
Year: 2005
Pages: 178
Authors: Craig Hunt

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net