Incoming mail handler for repmgr

One of the basic building blocks of most halfway interesting data-management systems is the ability to process email. This can take one of two forms: either the mail should simply be regarded as data, or it may actually contain instructions. Either way, we require a system component which can accept mail and do something with it. That component is the mail handler. It is important to note that the mail handler is concerned with incoming mail. Outgoing mail is created by a notification adaptor. Quite a different beast, as a mail handler is actually a client application and thus calls the wftk instead of being called by it.

Ideally, there would be two different mail handlers, one for the repository manager and one for the bare wftk core. However, as I'm not actually using wftk-bare, I'm not terribly motivated to work with it. So I'm concentrating on the repmgr first.

Actually handling mail is really not a terribly onerous task. Most of the work consists of parsing the MIME format and deciding which bits of it are useful text. That's done in the mail reader, which is called by the handler application.

Once the mail is parsed, we simply add it as an object. The add operation may well involve indexing into a database, or the execution of arbitrary workflow code. From this vantage, we neither know nor care. Note that this may mean a scaling vulnerability -- if considerable work is done to add the object, the mail handler may not be the place to do that work, as a mail handler process is created for each and every mail received. If you experience scaling difficulties with incoming mail, one tuning suggestion might be to drop mail into a standard mbox and use the LIST_mbox adaptor to read it in a periodic batch.

Here are the command-line flags the mail handler will look at:
-rSpecifies location of repository definition.
-lNames the list into which this mail should be added.

This code and documentation are released under the terms of the GNU license. They are copyright (c) 2002, Vivtek. All rights reserved except those explicitly granted under the terms of the GNU license. This presentation was prepared with LPML. Try literate programming. You'll like it.