Salvaging a deleted message from Thunderbird

undeleteSuppose you got an important mail, but by accident deleted the message – and to make matters worse, you also decided that emptying the mailbox was a pretty neat idea. Is then time to Panic?

Well it might, but there is a chance you might be able to undelete the message – and quite easily if you’re on a Mac or a Linux machine. Here are the few steps, which has helped recover a lost mail or two… First close Thunderbird. Then located the mail directory (on Linux it’s located in the subdirectory .mozilla-thunderbird in you home directory – on windows most likely somewhere in C:\Documents and Settings\*\Application Data\Thunderbird – In there you’re looking for the “Local Folders” directory.

If you’re on a Mac or Linux type the following:

cat Trash | grep -v X-Mozilla- > Restored

The cat command prints all the line in the file Trash – not to the screen, but as input to grep. Grep is used to find all lines not begining with “X-Mozilla-“ and prints these – and the greater than makes the print go to a new file called Restored.

Once this is done exit the directory and restart Thunderbird. You should now be able to find a new folder called “Restored” and a lot of old mail. Find the message you need to restore, and drag it into the inbox or wherever you need it – then delete the “Restored” folder.

If you’re on windows you need to do a little more work. The trick happening with the command line above, is that all lines beginning with “X-Mozilla-” is deleted and thus restored from their deleted state. A suitable editor might do the trick.

Do notice, that the Trash folder may be quite large, if you haven’t run the “Compact Folders” in quite a while – and if you did do that after deleting the message you’re trying to restore, then it’s probably gone for good.