Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

My institution recently reshuffled our email accounts. I'm forced to shift years worth of carefully currated email (= more chaos than a 3 year old's birthday party) from IMAP account_old to IMAP account_new which differ only in server names as far as I can tell.

Being IMAP, all my mail is held locally besides on the mail server, so I thought Thunderbird might allow me to create the IMAP account_new and then push the contents of my ~/.thunderbird profile onto the account_new IMAP server. Note also that the IMAP account_old is now offline.

My google searching has returned nothing on this approach and instead users appear to have to laboriously copy mail (by right clicking on folder > Copy To > relative/thunderbird/path), folder by folder, from one account to another. I was doing this until I discovered that, at some point, the attachments stopped being copied across correctly (but they were when I started the process). Specifically, the attachment file container is copied, but the contents appear absent since an error* is returned when attempting to open it. Same issue occurs using Move To on individual mail items. Right now I'm wondering if DavMail (for the Exchange account I use) is interfering with the copying of attachments using this approach.

* This attachment appears to be empty. Please check with the person who sent this. Often company firewalls or antivirus programs will destroy attachments.

No less, I'd like to know if there isn't a more robust and less labor intensive way to upload the entire local contents of an account to an IMAP server, with complete tree structure and metadata (fwd, reply, tags etc)? I'm using Thunderbird v17.0 on Ubuntu 12.04, 64bit, DavMail 4.1.0.

EDIT: I see imapsync should do the job. Any comments on this approach, i.e. are the metadata and attachments faithfully synced?

share|improve this question
Why don't you just copy a archive of the emails, configure a new IMAP account, and then transfer the emails to the new IMAP account? – Ramhound Nov 28 '12 at 16:49
@Ramhound Archive? as in ThunderBird has something like an 'export all mail with metadata to archivefile.tar.gz'? I don't see this option in TB, or are you referring to another program/script? – kbrand Dec 2 '12 at 22:08
Setup a traditional POP3 account. Copy each email currently on the Exchange/IMAP account. Create a new Exchange/IMAP account then copy the files back. – Ramhound Dec 3 '12 at 0:13
@Ramhound Sounds logical. My hesitation with this approach is that "Copy each email" sounds quite similar to "labouriously copy mail (by 'right click on folder' > 'copy to' > relative/thunderbird/path), folder by folder". Certainly it may be a workaround to this currently broken approach (at least for attachments copying). But with 50,000+ emails spread over dozens of folders i'm still hoping for a simpler global approach. Or do i misunderstand your suggestion? – kbrand Dec 5 '12 at 12:09
This is exactly what I was trying to suggest. This is clearly a limitation of Thunderbird, since it doesn't copy your attachments right, I figured what you wanted was a workaround? – Ramhound Dec 5 '12 at 12:16

2 Answers 2

An alternative is to use mbsync from the isync project. Here is some example configuration for syncing mail from one IMAP server directly to another:

# The IMAP server you wish to copy mails from.
IMAPAccount imap-src-account
User student0192
# Pass "xxxxx" # if you don't mind storing it in the file; otherwise will prompt
UseIMAPS yes
CertificateFile /etc/ssl/certs/ca-certificates.crt

 # The IMAP server you wish to copy mails to.
IMAPAccount imap-dest-account
# Pass "xxxxx" # if you don't mind storing it in the file; otherwise will prompt
UseIMAPS yes
CertificateFile /etc/ssl/certs/ca-certificates.crt

 # Link IMAP server to remote used below
IMAPStore imap-src
Account imap-src-account

IMAPStore imap-dest
Account imap-dest-account

# ensures that dates of messages will be set correctly
CopyArrivalDate yes

Channel transfer
Master :imap-src:
Slave :imap-dest:
# Transfer all folders
Patterns *
Create Slave
Sync Pull
# important otherwise you will get 'Error: store ... does not support in-box sync state'
SyncState ~/.mail/imap-transfer

You can then run mbsync -l transfer to list which mail folders will be synchronized.

To actually run the transfer, run mbsync transfer. The nice thing about this is that you can run that periodically and it will do an efficient sync.

Further notes:

  • passwords: You can also specify a PassCmd to use a different method of getting the password (e.g. from a token ring).
  • backups: Most instructions online for mbsync are using this to backup to a local file system. You can even backup to the local file system and then push it to the new server, as described here, but that's more complicated than necessary if you just want to sync the servers
  • folder mapping: if you want to transfer folders to a subfolder in the target system (as I did), you can specify this by saying Slave ":imap-dest:parent-folder/" in the Channel configuration.
share|improve this answer

Imapsync is a tool designed to do imap synchronizations, it syncs:

  • the whole folders hierarchy. The folders mapping can be changed.
  • all the messages, as is, attachments faithfully synced. Selecting messages by date/size is possible.
  • all the flags, at least all the ones that are enable by the destination server.

Imapsync allows incremental syncs, I call them a presync, to backup or speed up the final sync; it estimates ETA based on messages transfer rate measured. The author, Gilles Lamiral the name, sells it 50 EUR but it's available for free on github.

share|improve this answer
Unless i misunderstand Imapsync, the server with the source IMAP account needs to be online right? And in my case, as i indicated: "Note also that the IMAP account_old is now offline." But good to know all mail meta data is faithfully copied when used. – kbrand Jul 25 '14 at 21:26
You're right, if the imap server is down then imapsync nor any imap thing can't do anything. I misread your full description. – Gilles LAMIRAL Jul 27 '14 at 8:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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