[Dovecot] Moving new email from the mail spool to the inbox
tss at iki.fi
Wed May 9 10:25:37 EEST 2007
On Sat, 2007-05-05 at 14:48 +0100, Adrian Barker wrote:
> That's right: we cannot change the way that we deliver email, at least
> in the short to medium term, so need to maintain compatibility with the
> UW IMAP server. If we do decide to write a plugin that copies new email
> from the mail spool to the IMAP inbox, is there any documentation on how
> to write plugins ? I could not find any on the wiki.
There's currently no documentation for them. You could look at mail-log
plugin or quota plugin for an example. In any case what you'd want to do
is hook into sync_init() and do the moving there before calling the
There are two ways to do this:
a) Dummy copying to ~/mbox. This is slower because then Dovecot needs to
reread the new messages from ~/mbox and write X-UID etc. headers.
b) Open /var/mail/user as read-only mailbox with in-memory indexes.
You'll need to temporarily add MAIL_STORAGE_FLAG_FULL_FS_ACCESS to
storage->flags so that you can open the mailbox. Then use mailbox_copy()
to copy them to ~/mbox.
In both cases after copying is successful, truncate the /var/mail/user.
If something went wrong... well, you should probably at least try to not
leave duplicate mails lying there. With b) option it's easy with
See lib-storage/mail-storage.h and lib-storage/mail-storage-private.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://dovecot.org/pipermail/dovecot/attachments/20070509/d67efefd/attachment.pgp
More information about the dovecot