Build a Milter
A Milter is a program that listens on a socket. It receives each email message interactively on that socket from sendmail and receives each message in pieces. The sendmail program first offers the connection information, and the Milter can take it for review or decline it. If it accepts, it will screen that information and either reject the message based on its review or allow the message. Then the next piece of the message is offered and reviewed in the same manner. The order of the review is:
- Connect
Review based on the IP address and hostname of the connecting site
- Greeting
Review based on the hostname given as part of the SMTP HELO or EHLO command
- Sender
Review the envelope sender as supplied as part of the SMTP MAIL From: command
- Recipient
Review the envelope recipient as supplied as part of the SMTP RCPT To: command
- Headers
Review the header portion of the email message
- Data
Review the SMTP DATA command
- EOH
Signals the end of the header portion of the message
- Body
Review the message body, which can include MIME-encoded portions
- EOM
Signals the end of the body portion of the message
The program must quickly (within the timeouts defined by the
X
configuration
command) parse the message pieces and decide whether the
message should be accepted or rejected. The program then
advises sendmail of its decision, using
the libmilter API.
The sendmail source distribution includes a library and sample program that you should use to create your own Milter program. Look in the directory libmilter ...
Get sendmail, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.