The following pseudocode describes the filtering process from
the perspective of a set of N MTAs, each corresponding to an SMTP connection.
For each of N connections { For each filter process connection/helo (xxfi_connect, xxfi_helo) MESSAGE:For each message in this connection (sequentially) { For each filter process sender (xxfi_envfrom) For each recipient { For each filter process recipient (xxfi_envrcpt) } For each filter { For each header process header (xxfi_header) process end of headers (xxfi_eoh) For each body block process this body block (xxfi_body) process end of message (xxfi_eom) } } For each filter process end of connection (xxfi_close) }
|
The callbacks within parenthesis are placed beside the processing
stages in which they are called. If a callbacks is not defined for
a particular stage, the filter application can bypass that stage.
The filter application can abort processing at any time during a
message, in which case the xxfi_abort() callback is invoked and the control returns to MESSAGE.
Sendmail contacts the filter applications in the order defined
in the Sendmail configuration file.
To write a filter application, you must invoke different callbacks
to process relevant parts of a message transaction. The Milter library
then controls all sequencing, threading, and protocol exchange with
Sendmail.
Table 3-1 “Milter Callbacks Related to an SMTP Transaction” outlines the control
flow for a filter process and denotes different callbacks invoked
during an SMTP transaction.
Table 3-1 Milter Callbacks Related to an SMTP Transaction
SMTP Commands | Milter Callbacks |
---|
(open SMTP connection) | xxfi_connect() |
HELO ... | xxfi_helo() |
MAIL From: ... | xxfi_envfrom() |
RCPT To: ... | xxfi_envrcpt() |
[more RCPTs] | [xxfi_envrcpt()] |
DATA | |
Header: ... | xxfi_header() |
[more headers] | [xxfi_header()] |
| xxfi_eoh() |
body... | xxfi_body() |
[more body...] | [xxfi_body()] |
. | xxfi_eom() |
QUIT | xxfi_close() |
(close SMTP connection) | |
Although Table 3-1 “Milter Callbacks Related to an SMTP Transaction” denotes
only a single message, multiple messages can be sent in a single
connection. The remote host or Sendmail can abort a message and
connection anytime during the SMTP transaction. If the abort occurs
during a message processing (that is, between the MAIL command and the final . command), the filter application calls the
xxfi_abort() API. The filter application calls xxfi_close() any time when the connection closes.