1

I run my own mail server. It uses procmail to filter incoming mail, which is then stored in maildirs and gets served out my MUA using IMAP. I've got about 1.5GB of email is 135000 inodes.

This all works very nicely. However, I'd rather like to stop using maildir and switch to something more efficient --- maildb, or Dovecot's dbox, for example. Unfortunately, procmail can only deliver to a very limited set of backing store formats (Maildir, MH and mbox, AFAICT).

What I'd really like to do is to persuade procmail to deliver email via IMAP, rather than writing it directly to the backing store; this means that I can change the backing store format whenever I like without needing to reconfigure procmail. But I can't find any way of doing this. Any ideas?

(I'm also interested in any other mail filter tools that work like procmail but support IMAP. The only other filter tool I know is maildrop --- but that has similar restrictions to procmail.)

David Given
  • 13,277
  • 9
  • 76
  • 123

2 Answers2

4

Okay, here's a proper solution.

The cone project (http://www.courier-mta.org/cone/cone00index.html, Debian project: cone) has a very handy tool called mailtool which will copy files between mailbox types, including remote IMAP servers.

So, to deliver a message to a remote mailbox, you need a script which:

  • writes out the incoming message to a file (which becomes a one-message mbox folder)
  • does mailtool -tofolder destinationfolder -copyto imaps://username:password@server.com mbox:/full/path/to/message.mbox

That will then upload the message.

I don't actually need to do this any more so don't have a prepared script to post, but of the eight or nine different IMAP tools available, this was the only one that would actually do this, so it's worth documenting as such.

David Given
  • 13,277
  • 9
  • 76
  • 123
2

As a partial answer to my own question, it seems that Dovecot does come with a deliver tool specifically designed for this kind of thing; it works from procmail with a line like:

| /usr/lib/dovecot/deliver -m "Folder.Name"

...and it figures out all the rest of the settings automatically.

So now I can change the Dovecot mail storage format and everything will still work; but I'd still like an approach that actually uses IMAP to deliver the messages, so that I can try IMAP servers other than Dovecot's.

David Given
  • 13,277
  • 9
  • 76
  • 123
  • 1
    Using IMAP for message delivery sounds somewhat wacky. Your MTA delivers to a mailbox of some sort; in order for IMAP to do something useful, the mailbox needs to be in a format which the IMAP server understands. In Dovecot's case, they solved this by creating a binary which exposes the message store to the MTA for writing. Or you could use a message store format which is supported by both your MTA and your IMAP server. If you really need this, create a binary like the `deliver` tool which delivers over IMAP; but I don't think it can scale to general usefulness. – tripleee Sep 09 '11 at 07:24
  • 1
    No. If you are using Dovecot now, you will be hard pressed to find anything better. Delivering via IMAP is nuts. Your approach of invoking Dovecot's LDA from procmail is sound. If you are using Dovecot, you want to be using Dovecot 2, and make sure you're using 2.0.13 or better. – zgpmax Feb 14 '12 at 23:33