Transferring Email From Gmail/Google Apps to Dovecot With Larch

By eric

As regular readers of this blog know, I am in the process of trying to back up Google Apps accounts to Dovecot. Well I have finally found my solution. Not only does it work, but its in Ruby.

First thing that you’ll need to do is grab yourself a copy of Larch. I did this simply by typing and it installed everything nicely, but click the link to the repository on Github if it doesn’t work for you.

1
$ sudo gem install larch

Immediately I dove in and ran it. And immediately I hit my first problem:

1
2
3
$ larch --from imaps://imap.gmail.com --from-user user@gmail.com --from-pass FILTERED --to-pass me@myserver.com --to-pass FILTERED --all
... Removed for brevity ...
NameError: uninitialized constant Larch::IMAP::OpenSSL (cannot recover)

The fix for this issue is that SSL needs to be available (or installed as a library) to Ruby. Since I have Ruby built from source, it was just as easy as what’s below. I have removed the output for readability.

1
2
3
4
$ cd /usr/local/src/ruby-1.8.6/ext/openssl
$ ruby extconf.rb
$ make
$ sudo make install

Now that we have SSL installed, let’s try it again.

1
2
3
[Dec 07 16:54:06] [info] user1@googleappsdomain.com@mail.mydomain.com: Net::IMAP::NoResponseError: Mailbox doesn't allow inferior mailboxes (will retry)
[Dec 07 16:54:09] [fatal] Net::IMAP::NoResponseError: Mailbox doesn't allow inferior mailboxes (giving up)
[Dec 07 16:54:09] [info] 69 message(s) copied, 0 failed, 0 untouched out of 69 total

Whoops, another stopping point. If you are receiving the above error, then you need to make sure that your dovecot installation is set up for maildir. What this error is saying is that your installation doesn’t support folder that are folders and mailboxes at the same time. If your current dovecot installation is setup for mbox, you will need to convert it. That is beyond the scope of this post, but add the code below in the /etc/dovecot.conf if it’s not already there.

1
2
3
4
5
6
mail_location = maildir:/var/spool/mail/vhosts/%d/%u/Maildir
namespace private {
separator = /
prefix = ""
inbox = yes
}

I have been happily and successfully running Larch ever since.

Follow My Travels

Buy My Book

Archives

  • 2020
  • 2019
  • 2017
  • 2014
  • 2013
  • 2012
  • 2011
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006

New Posts By Email

writing