A bunch of us are in Copenhagen working on the blogger. We want to implement email blogging/moblogging and we're discussing the best way to handle incoming email in OpenACS.
Approach 1: Script Handler
In qmail and most other mail servers it is possible to have email bound for a given address (or domain) to be handled by a script. In qmail this is done by having a
.qmail-default file with
/path/to/scriptwill then be called and the message contents will be piped to the script in standard input.
That script would probably do some MIME parsing. It will then send the mail to OpenACS, either with a HTTP POST or an XML-RPC call. (Possibly it could also put the mail contents directly into the database with nstcl. However this would not be very different from the next approach.) An OpenACS Tcl script or XML-RPC handler will then process the mail according to some mapping defined by service contracts.
Pro: This approach is supported by almost all mail servers on Unix. If the script is written in Perl or Python, it could take advantage of the excellent MIME libraries that exist for these languages. Email can be handled much more synchronously, perhaps immediately, which is useful for "live" applications such as moblogging. (Note: If OpenACS is too busy the script should return an error, and the email server should retry later. Mail servers are good at queueing stuff.)
Con: This approach would probably not scale as gracefully for things like bounce handling. It requires an external script which might have dependencies like MIME libraries.
Approach 2: Sweeper
This is the approach currently implemented in acs-mail-lite. It works well for somewhat asynchronous applications like bounce handling and notification replies.
The approach involves the mail server putting all the messages in a Maildir-type directory. A scheduled proc then sweeps the directory, loads all the messages into the database, and sends them off to various handles registered with service contracts.
Pro: This approach will generally be faster than approach 1 above. It is already implemented in acs-mail-lite and appears to work well.
Con: It won't work well for applications where the user expects a near-immediate response. Procs scheduled to run more frequently than once a minute often cause problems.
Which approach is better? Would it be a good idea to support two types of incoming email, a script handler for immediate response and a sweeper for less time-sensitive apps?