Crate indymilter_test

source ·
Expand description

A library for testing milters.

The API provided is powerful, but rather low-level. It provides little guidance on how to interact with the milter under test. You must be familiar with the steps of an SMTP conversation. See the included tests for basic usage, and consult the sendmail API documentation.


The purpose of indymilter-test is exercising some milter and checking that it behaves as expected. Running the milter is out of scope for this library. You must arrange for the milter to be set up and torn down yourself. In any case, indymilter-test requires to be passed a listening socket to talk to the milter under test.

The main API item is TestConnection. Open the connection directly with TestConnection::open or configure it with TestConnection::configure.

When designing a test case, keep in mind that your method calls on TestConnection should be those of a well-behaved MTA. The sequence of steps will usually be: open the connection, interact with the milter under test while asserting expected responses, close the connection. As mentioned, familiarity with the milter protocol is assumed.

As a quick overview, the following are the SMTP commands that an MTA may forward to a milter, in order. Negotiation is done automatically when opening the test connection.

During the message-scoped commands, abort aborts processing for the current message. The commands indicated may be called repeatedly.

Cargo features

The optional feature regex enables implementations of Matcher for regular expressions.



  • An end-of-message action performed by a milter.
  • The stage for which macros are sent.
  • Socket information.
  • The status returned for a milter command.
  • Errors that may occur when interacting with the milter API.



  • Returns a matcher that accepts any input.

Type Aliases

  • A result type specialised for test errors.
  • The type of the milter protocol version.