Configuring Sendmail for milter-greylist

Add the following to the bottom of your script:

define(`confMILTER_MACROS_CONNECT', `j, {if_addr}')dnl
define(`confMILTER_MACROS_HELO', `{verify}, {cert_subject}')dnl
define(`confMILTER_MACROS_ENVFROM', `i, {auth_authen}')dnl
define(`confMILTER_MACROS_ENVRCPT', `{greylist}')dnl

You can also specify timeouts if you like, the following example has a one minute timeout when sending information to the milter and the same waiting for a reply, the defaults are just 10 seconds each and may not be enough when using DNSRBL and/or SPF. Read more at Sendmail milter installation.

INPUT_MAIL_FILTER(`greylist',`S=local:/var/milter-greylist/milter-greylist.sock, F=, T=S:1m;R:1m')dnl

Make the file from the m4-file. Many systems have a Makefile that will do this automagically.

/usr/bin/m4 /usr/share/sendmail/cf/m4/cf.m4 > sendmail

Restart sendmail.


  • If you have the spamd and/or clamd INPUT_MAIL_FILTER installed, be sure to have the greylist INPUT_MAIL_FILTER last, otherwise things will not necessarily work.
  • In Fedora RPMs or yum installations, notice that the socket location is "/var/run/milter-greylist/milter-greylist.sock". The correct line for is therefore INPUT_MAIL_FILTER(‘greylist’,‘S=local:/var/run/milter-greylist/milter-greylist.sock’)dnl

Sendmail timeouts

Sendmail lets you specify timeouts for various phases of the mail transaction. Some of the default values are ridiculously high due to what's recommended in the RFC:s. For instance, up to an hour waiting for the next command to be issued. This can result in lots of Sendmail processes just using up system resources better needed by milter-greylist. Here's an example with shorter times:

define(`confTO_ICONNECT', `15s')dnl
define(`confTO_CONNECT', `3m')dnl
define(`confTO_HELO', `2m')dnl
define(`confTO_MAIL', `1m')dnl
define(`confTO_RCPT', `1m')dnl
define(`confTO_DATAINIT', `1m')dnl
define(`confTO_DATABLOCK', `1m')dnl
define(`confTO_DATAFINAL', `1m')dnl
define(`confTO_RSET', `1m')dnl
define(`confTO_QUIT', `1m')dnl
define(`confTO_MISC', `1m')dnl
define(`confTO_COMMAND', `1m')dnl
define(`confTO_STARTTLS', `2m')dnl

The default values can be found here: Sendmail Tweaking.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License