BrT

Musings about technology and other neat stuff

BrT random header image

Installing a local IMAP server and moving from Evolution

January 31st, 2005 · No Comments

Note: some time has passed since I wrote this article. While the general idea still holds, the dovecot configuration format has changed in recent versions, so please don’t use the file I show here blindly.

I recently switched all my locally-stored email in my work machine from Evolution 1.4 to a local IMAP server, using the Maildir folder format. The motivation for this was that I have been using Evolution (1.4) for a while, and wanted to give Thunderbird a try. But with my messages stored in Evolution’s local format, it was difficult to seriously test Thunderbird. A comment posted in this article gave me the idea I was looking for: install a local IMAP server, then you can switch email clients as much as you want, always having access to your messages. I decided to try Dovecot, the IMAP server mentioned there.

So here’s what I did.

  1. Dovecot is in Gentoo’s portage tree, although the latest version is masked:
    echo "net-mail/dovecot  ~x86" >> /etc/portage/package.keywords
    emerge -v dovecot
  2. The default Dovecot configuration in /etc/dovecot.conf is mostly OK. These are the lines I currently have uncommented there (this is for dovecot 1.0rc27):

    protocols = imap imaps
    listen = localhost
    disable_plaintext_auth = no
    shutdown_clients = yes
    ssl_disable = yes
    ssl_cert_file = /etc/ssl/dovecot/server.pem
    ssl_key_file = /etc/ssl/dovecot/server.key
    mail_location = maildir:~/.maildir
    protocol imap {
    }
    protocol pop3 {
    }
    protocol lda {
      postmaster_address = postmaster@example.com
    }
    auth default {
      mechanisms = plain
      passdb pam {
        args = "*"
      }
      userdb passwd {
      }
      user = root
    }
    dict {
    }
    plugin {
    }

    This configures it to store everything under each user’s $HOME/.maildir directory, in Maildir format, and to authenticate using the existing system accounts.

  3. To convert my Evolution mail folders to Maildir format, I found the mb2md.pl script. This script can pretty much convert everything (including read/unread status, some Evolution headers, etc.). It can also do recursive conversion, but first I had to put all the Evolution folders in a structure that only contained the mailbox files. For this, I wrote this script. You run it like this:
    cd $HOME/evolution/local # Important, the script assumes relative paths
    find . -name mbox -print | xargs ./evo2mbox.sh

    It will copy all your evolution mbox files under $HOME/tmp/mboxes, named with the corresponding mailbox name. If a mailbox contains subfolders, its name will have “_f” appended, to differentiate it. Your Inbox folder will be renamed to “oldInbox” so that it does not conflict with the IMAP-provided Inbox. You can later adjust and rename things by hand as needed.

  4. Finally, convert your mbox folders to Maildir:
    mb2md.pl -s $HOME/tmp/mboxes -d $HOME/.maildir -R
  5. Now, start Dovecot with /etc/init.d/dovecot start, and configure your email client to connect to the IMAP server at localhost, authenticating with your Unix account and password. Hopefully, all your mail should be there.
  6. I had to change my procmail configuration file so that the default rule delivers the messages to my new Maildir inbox:
    :0
    ${HOME}/.maildir/
  7. I modified my local postfix configuration, so that email sent locally is also stored in the corresponding .maildir directory. In /etc/postfix/main.cf, I set:
    home_mailbox = .maildir/
  8. I think that’s it! Drop me a comment if you find anything wrong or missing.

Tags: · ·