2000-03-01-13:46:36 Phil Staub:
> While I have some legacy MH folders that I would rather not
> re-format, I don't have enough knowledge of maildir to have known
> that one-file-per-message is possible with it. Looks like some
> further study is indicated.
Lemme try and give you a running start.
<URL:http://www.qmail.org/qmail-manual-html/man5/maildir.html>
<URL:http://cr.yp.to/proto/maildir.html>
And a brief, informal overview.
A maildir folder is a directory structure. Given a folder named
"foo", there are three directories:
foo/tmp/
foo/new/
foo/cur/
(in the order that messages flow through the dirs). To deliver a new
message to a maildir, you write it into tmp, close it, then rename
it into new. The file should be named to guarantee uniqueness; djb
recommends time.pid.hostname, or, if one process wants to write
multiple messages, time.pid_count.hostname. Once it's renamed into
new/, delivery is complete. MUAs pick up new messages from new/.
When they want to change the status of the message, they rename it
into cur/, and they can stash flags (e.g. "replied-to", "seen",
"marked-for-deletion", etc.) in the filename; djb has specific
recommendations on how to do that.
Here's a pretty safe maildir writer. Djb has some more rules for
further paranoia; but the real world is not likely to bite you if
you deliver messages like this. Written in Bourne Shell, but of
course it codes into very lean, tight code in most any language.
f=`date +%s`.$$.`hostname`
cd $maildir
cat >tmp/$f
mv tmp/$f new/
-Bennett
PGP signature