Mailet Container Configuration

This documents explains how to configure Mail processing. Mails pass through the MailetContainer. The MailetContainer is a Matchers (condition for executing a mailet) and Mailets (execution units that perform actions based on incoming mail) pipeline arranged into processors (List of mailet/matcher pairs allowing better logical organisation). You can read more about these concepts on the mailet container feature description.

Apache James Server includes a number of pre-packaged Mailets and Matchers. Futhermore, you can write and use with James your own custom matchers and custom mailets.

Consult mailetcontainer.xml in GIT to get some examples and hints.

The body of this element is the address that the server will consider its postmaster address. This address will be listed as the sender address of all error messages that originate from James. Also, all messages addressed to postmaster@<servername>, where <servername> is one of the domain names whose mail is being handled by James, will be redirected to this email address. Set this to the appropriate email address for error reports If this is set to a non-local email address, the mail server will still function, but will generate a warning on startup.
Number of simultaneous threads used to spool the mails.

The Mailet Tag

Consider the following simple mailet tag:

<mailet match="RemoteAddrNotInNetwork=" class="ToProcessor">

The mailet tag has two required attributes, match and class.

The match attribute is set to the value of the specific Matcher class to be instantiated with a an optional argument. If present, the argument is separated from the Matcher class name by an '='. Semantic interpretation of the argument is left to the particular mailet.

The class attribute is set to the value of the Mailet class that is to be instantiated.

Finally, the children of the mailet tag define the configuration that is passed to the Mailet. The tags used in this section should have no attributes or children. The names and bodies of the elements will be passed to the mailet as (name, value) pairs.

So in the example above, a Matcher instance of RemoteAddrNotInNetwork would be instantiated, and the value "" would be passed to the matcher. The Mailet of the pair will be an instance of ToProcessor, and it will be passed the (name, value) pair of ("processor", "spam").

Error handling

If an exception is encountered during the execution of a mailet or a matcher, the default behaviour is to process the mail using the error processor.

The onMailetException property allows you to override this behaviour. You can specify another processor than the error one for handling the errors of this mailet. The ignore special value also allows to continue processing and ignore the error.

Moreover, the onMatcherException allows you to override matcher error handling. You can specify another processor than the error one for handling the errors of this mailet. The matchall special value also allows you to match all recipients when there is an error. The nomatch special value also allows you to match no recipients when there is an error.

Here is a short example to illustrate this:

<mailet match=RecipientIsLocal class="LocalDelivery">