8

I have an IMAP mail server and use Thunderbird as my client. I didn't understand the sychronization of client-server using IMAP vs POP. My IMAP server was filling up, so I logged onto the server and deleted the Inbox thinking that Thunderbird had local copies of the mail.

When I opened Thunderbird, it synched against the IMAP server and marked all my email as deleted. The emails still exist in the {path}/thunderbird/profile/default/INBOX file fortunately. After some research on the net, I edited that file and changed all the “X-Mozilla-Status:0001" to "“X-Mozilla-Status:0000".

When I brought Thunderbird back up, the emails were still gone. Does anyone know how to recover these?

masegaloeh
  • 17,978
  • 9
  • 56
  • 104
Matt Brown
  • 181
  • 1
  • 1
  • 2

4 Answers4

9

I had a similar problem - through some quirk a bunch of emails disappeared from my IMAP server, but remained in the INBOX and Sent files on the local drive. I was unable to coerce Thunderbird to restore those emails onto the IMAP server directly, so I went with another approach:

  • Create a POP3 account with the same credentials as the IMAP one, but make sure this account is unable to connect - don't enter your password.
  • Shut down Thunderbird, and navigate to /Profile/randomname.default/Mail/hostname_of_your_server/
  • Double-check that this is indeed your freshly created dummy account and not some other valuable, but similarly named POP3 account.
  • Copy over the Inbox file containing the deleted emails, overwriting the one from the dummy account, and delete the inbox.msf file that was also in that dummy account folder.
  • Start Thunderbird - notice you have all your emails back! Both the deleted and the undeleted ones are visible in the dummy POP3 account.
  • Now grap the Thunderbird "Remove duplicates (Alternate)" extension from here: Remove duplicates (Alternate).
  • Using the above extension, set the IMAP Inbox as the "Set original message folder(s) for next duplicate search", and run the "Remove duplicates" on the dummy POP3 Inbox.
  • Move the duplicate messages to Trash.
  • Move the remaining messages from the POP3 Inbox, to the IMAP Inbox. Thunderbird will re-upload all the messages automatically to the IMAP server.

Done!

Tomasz C
  • 91
  • 1
  • 3
  • 1
    +1, amazing! I had a similar scenario. Thunderbird wouldn't notice the email even though it had x-mozilla-status and status2 equal to 0 after the MSF was deleted. Plugging the email file into a dummy POP3 account did the trick. – Kos Apr 24 '13 at 09:08
  • I did a similar recovery by dragging all the files from ImapMail > "NameOfTheAccount" into Mail > Local Folders > Recovery. All my mails are there but all the structural information (subfolders, marked, read etc.) is gone. Any ideas on that? – Andi Giga Nov 21 '19 at 08:27
3

IMAP and POP are not the same! POP is a transfer protocol, pulling e-mail from the server to the client. IMAP is a synchronization protocol, keeping e-mail on the server, and usually keeping a local cache version.

IMAP has a two stage delete, though most clients don't separate them. They are: Mark as Deleted, and Purge Deleted. Like I mentioned, most clients do both at the same time.

Once an e-mail is purged from the server it should be flushed from any local caches, permanently deleting the e-mails, upon next synchronization. Changing a cache will not change the server.

Accidents are the reason you take good backups; so you can just restore the e-mails.

Chris S
  • 77,337
  • 11
  • 120
  • 212
  • 1
    "Accidents are the reason you take good backups" Thanks for scolding me, though I think I did a reasonable job admitting i didn't understand the difference between POP and IMAP. – Matt Brown Apr 15 '11 at 15:37
2

Here's a solution that doesn't require you to create a new pop-account.

It's good if you don't have a lot of mails or whole folders got emptied.

  • First of all: Always do a backup! To do that, just copy your profile located in (Linux) ~/.thunderbird/[random].default somewhere else
  • Navigate to your imap profile located in (Linux) .thunderbird/[random].default/ImapMail/[accountname]
  • Copy the folders, the files without .msf extension, to your local thunderbird folders located in .thunderbird/[random].default/Mail/Local Folders
  • Restart thunderbird and check your local folders.
  • Now you can just drag and drop the mails to your IMAP profile again

We noticed that some mails appeared twice in the new local folders, but just one of them was marked unread. So you can easily filter them.

0

so I logged onto the server and deleted

do you mean that you ssh'ed into the server? what kind of server is it? if it's running a snapshotting filesystem, it may be possible to recover the inbox from the snapshots...

anastrophe
  • 5,388
  • 2
  • 15
  • 16
  • 1
    snapshots would be a form of backup, which the Questioner already admitted he doesn't have. – Chris S Jul 11 '11 at 18:28
  • 2
    you may wish to reread the Questioner's comments, he did not 'admit' that he doesn't have any. if the email is hosted on a server he doesn't manage, that server may support snapshots which he may not be aware of. it's certainly worth investigating. – anastrophe Jul 11 '11 at 20:51