I love the free webmail services out there but hate having years of mail tied up in one of these products.

I'm looking for a way to cache a mailbox locally but still be able to access it from a locally installed imap client.

I looked at offlineimap, which looks great except its doing a two-way sync. If mail gets deleted in gmail, it will also delete it in my local copy. There doesn't appear to be a way to configure it to do something that looks more like traditional pop access where the new message is copied locally and deleted from the remote source.

Has anyone done something like this before? I'm not tied to imap. If there is a pop based solution out there, I'm all ears. I'm using ubuntu 11.10.


The current behavior you describe is called "one-way sync" – all changes in one side, including deletion, are propagated to the other side.

For a permanent cache, look into getmail or fetchmail.

# ~/.getmail/getmailrc
  type = SimpleIMAPSSLRetriever
  server = imap.gmail.com
  username = ...
  password = ...
  type = Maildir
  path = ~/backup/gmail

Both these programs support fetching from IMAP and POP3 mailboxes, but IMAP is usually preferred.


OfflineIMAP does support one-way sync (no updates to the actual mail server's mailbox), using the readonly = True option. See the sample configuration file in the official GitHub repository.

So your .offlineimap config file should contain:

[Repository Gmailserver-foo]
#This is the remote repository
type = Gmail
remotepass = XXX
remoteuser = XXX
readonly = true

this is my configuration file used to do one-way-sync from one gmail account to another

accounts = GmailMigration
socktimeout = 600
maxsize = 25000000

[Account GmailMigration]
localrepository = sourceAccount
remoterepository = dstAccount

[Repository sourceAccount]
type = IMAP
remotehost = imap.gmail.com
remoteport = 993
remoteuser = ...
remotepass = ...
ssl = yes
sslcacertfile = /etc/ssl/certs/ca-certificates.crt
readonly = true

[Repository dstAccount]
type = IMAP
remotehost = imap.gmail.com
remoteport = 993
remoteuser = ...
remotepass = ...
ssl = yes
sslcacertfile = /etc/ssl/certs/ca-certificates.crt

Basically you want is an archive of mails. One way you can achieve it is you can automatically forward mails from your current mail account to another mail account. Most of all free mail services provide this facility. Then you setup offlineimap to sync this second mailbox locally. And never delete any mail from this second mailbox. Use this mailbox for only archiving.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.