James Mailets and Matchers

Intended audience

This document is intended for people who want to understand how the James mailets and matchers fit in with Dithaka: the Dithaka-James component

Introduction

Dithaka uses JavaMail and James (Java Apache Mail Enterprise Server). James is a Java SMTP and POP3 Mail server and uses Mailets and Matchers. The Matchers is used to match mail and send it on to a mailet to be processed further. The matching is done either on the Mail object or the recipient mail addresses. Hibernate is used by Dithaka to persist the data.

What are Mailets and Matchers?

James provides an Java API for processing emails. The API is called the Mailet API which consists of mailets and matchers. Apache defines mailets and matchers as follows:

  • A Matcher is a simple object that checks whether a mail message matches a particular condition.
  • A mailet is another type object that processes an email message in some way. Some typical tasks appropriate for a mailet would be adding a header, delivering the message to a local repository, or handling remote delivery.
Mailets and matchers can be extended and they work in pairs.

Structure and inner working of Mailets and Matchers

Mailets and matchers are grouped into processors. The root processor is the first processor that is executed. The processors process the mail messages that are placed in the spool repository. When it has finished processing, the mail messages are placed back into the spool repository where it can be processed by the next processor. More information about the processors and the spool repository can be obtained from the James website: james.apache.org

The Dithaka mailets and matchers are located in the root processor.

The structure is shown in the diagram below:

Implementation

Mailets and Matchers used by Dithaka:

The following mailets and matchers are available in Dithaka:

  • ForumMatcher: This is the basic matcher that will check incoming and outgoing mail. It is used to check if any of the mail is related to a forum. If it is, the corresponding Mailet will be called.
  • ForumMailet: This class provides the basic forum capability of Dithaka. It is called if a mail message is found to be related to a forum. If emails are from the forum (outgoing) it assumes that the message has been saved and sends it on to the subscribers of the forum. If it is an incoming mail the server saves the message to the appropriate forum, processes the message and then ghosts the mail.
  • ForumMsgSizeMatcher: looks at the message size of the mail and sends it on to ForumNotifyMailet. This only occurs if the size of the message is larger than specified by the settings of the Mail Forum.
  • ForumNotifyMailet: will send a message to inform the list owner and the project champions of certain occurrences within Dithaka. Currently the message is hard coded, but will be extended and improved in later versions, when a full notification module is implemented.
  • ForumAddFooterMailet: is used to add a footer to the messages going out to the registered users of the forum. This footer can be set in the mail forum settings page that was added.
  • ForumListservProcessorMailet: is used to add the footer to outgoing messages and also modifies the messages by adding in prefixes, setting X-been-there headers, etc.

Sequence of James mailets and matchers in Dithaka:

James have a pool where mails are placed. These mails are taken out of the pool and processed by the matchers and mailets. The activity diagram below shows the sequence that a mail could take through the currently configured Dithaka mailets. The diagram does not show mails that can be generated by the mailets and put back in the pool.

James mailets and matchers Activity Diagram:

Known issues and future enhancements

Coming soon...