Migrating mail from Evolution local storage to Evolution + local Imap (dovecot with Maildir) 2/X

See previous post for the rationale.

I’ve then started migrating my mail using evolution.

First I’ve installed dovecot and set it up so as to store my mail inside my $HOME/Maildir/ dir. Evolution will run dovecot on demand through a pipe, instead of through network access like with regular remote IMAP servers. So dovecot won’t be started as a daemon. I’ve been inspired by Roland’s setup for this (even though I’not using offlineimap).

Inside Evolution, I’ve configured a second mail profile, for this local IMAP server, using the custom command to connect to server :
"MAIL=maildir:$HOME/Maildir /usr/lib/dovecot/imap"

I’ve migrated my existing mail folders using “copy to” function on all top-level mail folders from the local evolution storage, to copy them to the IMAP folders. Note that some folders that include a dot (‘.’) need to be renamed, as the dot is a path separator for IMAP.

I’ve adapted Evolution’s vfolders definitions so as to take into account the “active remote folders” instead of the local ones, and that’s it, the mail is migrated.

I’m using fetchmail + procmail to fetch mail from remote servers and to deliver it to the Maildirs, using dovecot’s deliver program, with something like :

DELIVER="/usr/lib/dovecot/deliver"

:0: w
| $DELIVER

I’ve migrated the filters of evolution to “server-side” Sieve rules so that dovecot’s deliver sorts incoming mail in the right Maildirs. The dovecot config needs to be adapted to activate the sieve plugin (dovecot-sieve Debian package), in /etc/dovecot/conf.d/15-lda.conf :

protocol lda {
# Space separated list of plugins to load (default is global mail_plugins).
mail_plugins = $mail_plugins sieve
log_path = /tmp/dovecot-deliver-errors.log
info_log_path = /tmp/dovecot-deliver.log
}

The original Evolution filters rules were stored in $HOME/.config/evolution/mail/filters.xml, so I wrote a quick python DOM parsing tool to extract the (long) list of definitions and generate Sieve rules for the $HOME/.dovecot.sieve config file (in which folder hierarchy uses a ‘.’ path separator instead of a ‘/’).

The sieve-test program can be used to check is sieve rules function as you want.

Now this is all setup, I only need to configure notmuch to index all the Maildirs. But this is left to another post.