Evolution 3 and offlineimap

2 minute read

I use offlineimap to fetch my emails from my Gmail account. I use labels as folders, some are nested, and some contains a dot in their names. I have about 120 of them. They contain my about 30000 messages and weight about 6 Gb.

After migrating to Evolution 3, new mails that go directly in folders stopped showing up in Evolution. Further, some of my emails starting to get their labels removed on my Gmail account.

As Evolution 3 stores messages in the maildir format, when you point it out to the folder where offlineimap synchronizes your emails, it starts by creating hidden folders with the same names and moves the current messages in them. So, if you start with a folder called let's say "Alerts", evolution will create a folder called ".Alerts". Your current ("cur") folder under "Alerts" will be emptied and moved in the "cur" folder under ".Alerts". The issue with this is that offlineimap interprets that you just removed the "Alerts" label to all your messages.

For the labels that are nested, Evolution actually now follows the maildir standard and use the dot as a separator. For instance, a Gmail labeled called "Alerts/Comments" will become in your maildir folder ".Alerts.Comments".

Furthermore, if you had a dot in the name of your label, let's say "2010.Archives", during the renaming folder process, Evolution 3 will convert this to ".2010_Archives".

How to fix this and make it work again?

  1. First, stop offlineimap to check for your account (cancel the cron job if it's how you tell offlineimap to check your account).
  2. Second delete your ~/.offlineimap folder so that modifications to your maildir folder are not interpreted as labels being removed.
  3. Start Evolution 3 and let it do all the renaming and moving around of your messages
  4. Close Evolution, delete all the cmeta, index and data files created by Evolution in the maildir directory
  5. Delete all the folders that used to contain your messages (after making sure that they're all empty)
  6. Edit your .offlinemaprc file:
    1. change sep=/ to sep=.
    2. change your nametrans line to: nametrans = lambda folder: re.sub('\s+', '', re.sub('(.+)(\\.)(.+)', '\\1_\\3', re.sub('(^.{1})', '.\\1', re.sub('.*Trash$', 'Trash', re.sub('.*Drafts$', 'Drafts', re.sub('.*Sent Mail$', 'Sent', re.sub('.*Starred$', 'Starred', re.sub('.*All Mail$', 'Archive', re.sub('^(INBOX)', ' ', folder)))))))))
    3. This series of regular expressions does the following:
      1. Every folder gets a dot appended in the front. '(^.{1})', '.\\1'
      2. Dots inside your labels are replaced with underscores (you'll need to change it if you have more than one dot in your labels): '(.+)(\\.)(.+)', '\\1_\\3'
      3. All the Gmail special folders are moved to the root (i.e., "[Gmail]/Trash" becomes "Trash")
      4. The Inbox folder is moved to the root of your directory. This is done in three steps, first "INBOX" is replaced by a space '^(INBOX)', ' ', then a dot is appended in front (like all the other folders) and the extra trailing space is then deleted '\s+', ''.
  7. Restart offlineimap and make sure that everything is working the way it's supposed to.

The process was a little bumpy but I can now read my emails in Evolution again.

Here you can download the full version of the .offlineimaprc file.

Leave a Comment