Setup for syncing a gmail with lots of emails

Rafael EspĂ­ndola rafael.espindola at
Wed Nov 16 03:52:41 GMT 2016

Just wanted to share the experience I had so far tuning offline imap
to work with my gmail account.

I never delete emails, so by now I have a lot of them. I also love
labels and really want to sync them.

I started with
The initial sync took a few days and created a 21 GB MailDir. That is
fine for an initial setup.

The issue I was then having is that each sync would take a few
minutes, even if there was only one new email. The problem is that -q
can only skip the sync if there is no new email and that is almost
never the case when syncing the "All Mail" label and being subscribed
to some open source project mailing list.

Adding a few prints I found that almost all the time was in

             res_type, response = imapobj.fetch("'%s'"% msgsToFetch,
               '(FLAGS X-GM-LABELS UID)')

And that was because it was getting information about all the
messages. Looking around the code for where min_date and min_uid were
coming from the solution I found was to, after the initial setup, add

sync_deletes = no

to both folders (I never delete email anyway) and add maxage to the
account. Now offlineimap finds the last uid I fetched in the last few
days and asks for just those, but doesn't delete any email.

If I ever change labels of old messages in gmail I will have to
remember to temporally comment maxage to sync the change but that is
probably fine.


More information about the OfflineIMAP-project mailing list