Mailbox format conversion plugin
================================

This plugin can be used to convert mails from one format to another when the
user logs in. The existing mails aren't deleted, only the directory is renamed.

This plugin requires that you have a home directory set, and that the mail root
directory isn't the same as home directory. So for example if you currently
have mails in '/var/vmail/user/', you first need to move them to e.g.
'/var/vmail/user/mail/'.

For example:

---%<-------------------------------------------------------------------------
mail_location = maildir:~/Maildir
protocol imap {
  mail_plugins = convert
}
protocol pop3 {
  mail_plugins = convert
}
plugin {
  convert_mail = mbox:~/mail:INBOX=/var/mail/%u
}
---%<-------------------------------------------------------------------------

This converts '/var/mail/user' INBOX to Maildir INBOX in '~/Maildir'. Also all
mailboxes in '~/mail/' are converted to Maildir mailboxes. Once everything is
finished,'~/mail' is renamed to '~/mail-converted' and at next login the
conversion isn't done, because the '~/mail' directory no longer exists.

UW-IMAP conversion
------------------

If your mailboxes exist in home directory among other files, you'll need to
use:

---%<-------------------------------------------------------------------------
plugin {
  convert_mail = mbox:~/:INBOX=/var/mail/%u
  convert_skip_broken_mailboxes=yes
}
---%<-------------------------------------------------------------------------

Otherwise the conversion stops at the first file which isn't an mbox.

UW-IMAP notes from Andrew Z
---------------------------

mbox:/home/%u seems to work better than mbox:~/ . Then, my Dovecot 1.0.1 fails
converting mboxes from ~, but it works after moving mboxes to ~/mail.   Also, I
was able to preserve subscriptions (to prevent manual re-subscriptions) by
copying ~/.mailboxlist to ~/Maildir/subscriptions (before first IMAP login). 
Don't forget the user must own the mail files in his directory.

Also it's worth to check if mbox directories do not contain files and folders
with names starting with '.', like .spamassassin and .profile. With such files
or folders convert plugin will fail, complaining about illegal names, and you
will get .imap subfolder in mbox folders, thus increasing the problems.

To automate moving mailboxes and preserving subscriptions, see this script:
http://www.dovecot.org/list/dovecot/2007-June/023757.html. A small fix on top
of it:

---%<-------------------------------------------------------------------------
-       cat .mailboxlist | while read line; do mv "${line}" ./mail/; done
+       cat .mailboxlist | tr '\n' '\0' | xargs -0 mv -t ./mail/
---%<-------------------------------------------------------------------------

(This file was created from the wiki on 2010-05-24 04:42)
