sample_milter - example mail filter module

Fetch the software.

Sendmail includes a facility for plugging in custom mail filters, called milters. It's documented here. This milter is intended as an example, to show how they work, and as a base for building your own milters.

The basic idea of a milter is, you initialize and specify a set of callback routines. Then as each message is received, sendmail will pass pieces of it to the appropriate callbacks. The callbacks can decide whether to accept or reject the message, and can also modify it in various ways.

In sample_milter, all the callbacks do is syslog that they were called and what their arguments were. This lets you see in realtime how the milter is working.

Installation

This is very abbreviated, intended mainly as a reminder for those who have worked with milters before. If it's your first milter, you should look on the web for more thorough documentation.

  1. Make sure your sendmail is compiled with the MILTER option. (Starting with version 8.13 this is enabled by default.) You can use this command to check:
    
    sendmail -d0.1 -bt < /dev/null | grep MILTER
            
    If you don't see MILTER in the compilation options, you will have to re-build sendmail.
  2. Build and install the sample_milter executable, by doing a 'make install'.
  3. Edit your sendmail.mc and add a mail filter macro, for example:
    
    INPUT_MAIL_FILTER(`sample',`S=unix:/var/run/sample.sock')
            
    Rebuild and install sendmail.cf.
  4. Run sample_milter, with the same socket argument you used in sendmail.mc:
    
    # sample_milter unix:/var/run/sample.sock
            
  5. Stop and re-start sendmail.
  6. Look in /var/log/maillog for messages from sample_milter.

See also: spfmilter, sfcmilter, blackmilter, graymilter.
ACME Labs / Software / sample_milter
email