Sendmail milter


Sendmail comprises a mail filter API (milter) which allows third-parties to hook up their filters into sendmail.

Installating sendmail with milter support

Download the sendmail source code from the Sendmail website.

  • Extract the files from the downloaded file.
  • Change the current directory to where the sendmail source code was extracted.
  • Edit devtools/Site/site.config.m4 and add the following statement:

    N.B. Milter is enabled by default in sendmail 8.13.x
  • Enter the following command:

    sh Build

  • If there are no errors, you may continue with the installation.
  • If you are installing sendmail 8.12.x or 8.13.x
    • Verify whether you have a user smmsp. Create the user if it does not exist. The user should not be assigned a login shell.
    • Verify whether you have a group called smmsp.
  • Enter the following command:

    sh Build install

The sendmail binary is now installed.

  • The following commands will install the libmilter library and include files:

    cd libmilter
    sh Build
    sh Build install

The next step is to configure sendmail.

Note: If you are using a sendmail RPM, install the sendmail-devel RPM.

Configuring sendmail

The main configuration file for sendmail is the /etc/mail/ file. Starting with version 8.12, sendmail uses the /etc/mail/ configuration file for mail submission. The .cf files are complex to understand. It is recommended that you create a .mc configuration file and use the M4 (macro processor) to generate the .cf file.

There are some sample .mc configuration files in the cf/cf/ directory of the sendmail source code. Alternatively, you can use one of the sample configuration files available from our website. You should edit the .mc file with a UNIX text editor such as vi.

  • Change the current directory to cf/cf directory.
  • Copy your .mc configuration file to the current directory as
  • Edit the file and add the line for your milter above the define lines
    INPUT_MAIL_FILTER(`milter_name', `S=unix:/var/tmp/milter_name.sock, F=T, T=S:240s;R:240s;E:5m')dnl
    N.B. If you have more than one milter, add a line for each of them.
  • To generate the, enter the following command:

    sh Build

  • To install the as /etc/mail/ and as /etc/mail/, enter the following command:

    sh Build install-cf

Order of milters

Several milters can be used with sendmail by adding INPUT_MAIL_FILTER lines for each of them. You can change the order in which the milters are called by placing the INPUT_MAIL_FILTER line for the one you want first.


Socket permission errors

You can get around file permissions reading the milter's Unix socket by using TCP sockets instead. e.g:

INPUT_MAIL_FILTER(`scam-back', `S=inet@8900@localhost, F=T, T=S:240s;R:240s;E:5m')dnl

Socket unsafe

This error generally occurs if the milter is not running. You should start the milter before starting sendmail.

Related links

Basic sendmail installation

Milter API

Open source milters


If you have any comments, you can contact the author here.