5

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?

  • 1
    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
5

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
Host imap.host.ac.uk
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
Host zimbra.corporate.com
User worker@corporate.com
# 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.
  • I tried this. All folders are copied, but INBOX is not – Lenne Aug 1 '16 at 11:55
  • You may need to look at the configuration and how your folders are mapped... – David Fraser Aug 4 '16 at 10:29
  • My inbox is at the root of the folders, /var/vmail/domain/user, not at ~user/mailbox or something So how do I map that, @david.fraser ? – Lenne Aug 4 '16 at 11:34
  • It looks like you can use the Inbox setting, see isync.sourceforge.net/mbsync.html – David Fraser Aug 5 '16 at 14:43
  • 1
    I was missing the SyncState tip, thanks! – Álex Oct 7 at 16:21
1

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.

  • 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
0

TL;DR

Repair the folder. PD: The information is not lost. It's there.

Context

I was affraid it was happening to me. I found this question because I started to "copy" my emails with customers in my travel agency into a temporary account to later import them into a database for automatic processing into a custom CRM... and loosing attached files from the customers was not an option.

I was getting the meessage This attachment appears to be empty. Please check with the person who sent this. Often company firewalls or antivirus programs will destroy attachments. after having deleted the original messages and I was very affraid of the situation.

And I was really, really affraid I lost the attachments.

So the first thing I wanted to clarify was:

CRITICAL QUESTION: Is thunderbird loosing information when copying the emails? Or it just copies it right but later it is unable to read it?

  • If thunderbird loosed information, that's a complete problem.
  • If just it is unable to read, no problem then.

What I did to resolve my critical question

a) I first looked into the source code of the message. It REALLY had "some" content. Boundary, then the attached file.

Source code of the email

I still did not know if the content was correct or corrupt.

b) I saved the email into the desktop, double-clicked it and opened it with thunderbird loading it from the desktop.

c) I then right-clicked to save the attachment. Once the attachment was saved I opened it (it was an Excel file in this cas) and Excel opened it well. So, first conclusion: the info inside the attachment is not lost

d) Then I opened the attachment directly by opening it from the email window (again: not from the IMAP, just viewing in thunderbird the .eml file in the desktop) and it opened correctly. So, second conclusion: the source of the message is not corrupting the info for double-clicking and opening the attached file

Answer (what worked for me)

I concluded then that the information was not lost (most probably the final IMAP source code is byte-per-byte a copy of the original source code) and then necessarily the problem is at reading/interpreting the message again.

But Thunderbird sometimes needs a bit of help. It "caches" some data to avoid connecting to the IMAP server each time, and for any reason IDK, from time to time, this information might get corrupted.

There is a way to solve this:

1) Right click your folder and select "Properties" on the troubling folder.

Select properties

2) Select "Repair". This invalidates the cached meta-data about the messages contained there and therefore it forces to re-download the source-code files that contain the headers and body of the messages, and re-interpret the content itself.

Repair the folder

It worked for me. Now I select the same message, I open the attach and no longer get the This attachment appears to be empty. message.

Hope to help!

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.