Protect Your Inbox: Tips for Preventing Email Loss on Postfix Server, Dovecot, and Thunderbird!

Discover how to recover emails from Postfix Server, Dovecot, and Thunderbird Mail Client with our essential guide. Whether you’ve encountered email loss due to server issues or client errors, this step-by-step tutorial will walk you through the process of recovering your valuable emails from Postfix Server, Dovecot, and Thunderbird Mail Client with ease.

Your browser does not support HTML audio, but you can still download the file.

Backup is an important part of the activity performed to maintain the server and the entire domain. Since the server is a crucial part of your network, make sure your backup your data regularly. If something goes wrong – for example, certain equipment breaks down – you will be able to restore the server’s operability using a backup copy. However, the problem in question is this: what can you do when there is no backup file, or when it’s impossible to restore the server from it? In this case, a special data recovery tool – Hetman Partition Recovery – is going to save you. With its help, you’ll be able to recover the lost emails from your server.

We will explore in detail how to back up your files and then recover data on a client machine, with the example of Thunderbird mail client in a Linux operating system, and how to restore emails on a server after reinstalling or formatting the hard disk – or even transfer all emails to a new server. For starters, let’s explore why you can lose access to your emails.

Why emails can be lost

The causes behind the loss of emails can be extremely varied. However, the main factors are these:

  • Accidental removal of a user’s folder on the client machine;
  • Server failures;
  • Mail server breakdowns;
  • Incorrect administration;
  • Loss of access to the mailbox;
  • Or erasing important data in case of reinstalling the operating system or accidentally formatting the hard disk.

Thunderbird user backup folder

Before you start looking for the lost data, you need to decide where email files can be found.

As we know, all emails that reach the server are written to a certain directory and stored until they are removed. Emails are deleted from the server when you remove them from your mailbox trash folder. When a mail client is used on a client machine, the messages are stored both on the server and on the client machine where the corresponding mail client is used.

For illustration, I’ll show you where user data files are stored in case of Thunderbird mail client, how to back them up, and how to recover them.

In a Linux operating system, Mozilla Thunderbird mail client keeps all user settings, passwords, addresses and email files on the user’s client machine. When the application is launched for the first time, it creates a default directory with a path like this:

Home/username/.thunderbird/

This folder is hidden so you can only view its contents in the mail client window - or you can change the settings to make hidden folders visible. Click on the Menu button and check the box for the option Show Hidden Files.

To open this folder, click Menu in the application windows, go to HelpTroubleshooting Information, and in the tab that opens, find the line Profile Directory and click on Open Directory. This will open the user folder in the Explorer window. In this folder, you can find the subfolders for calendar, settings, mail and so on.

Mozilla Thunderbird has no built-in tools for creating a backup copy of profile data or user’s correspondence files. That is why if you need to transfer a user profile to another computer or if your computer (or its operating system) fails for some reason, there are two variants - to use third-party software or create a profile backup manually.

To back up data, go several levels up and copy the .thunderbird folder to another drive.

A folder with a randomly generated name is created for every user. To transfer data to another computer you will have to copy the contents of this directory to the same folder but on the new computer.

How to recover data from backup

To recover data from backup of transfer it to another PC, install and run Thunderbird on the new computer. When launched for the first time, the application will create a new user folder with the path I have shown before. Close the program without changing its settings.

Follow the path to the profile folder and replace its contents with the files from the backup. When the operating system asks you about replacing the files, choose Replace.

After you launch the program again, you will sign in to the old user profile and you will see all the emails that existed at the time when the backup was created.

How to recover user data from a client machine after removal or formatting

If you accidentally removed a user from a client machine, the server is out of order, and you have no backup to rely on, use Hetman Partition Recovery to bring the data back.

In case of a server running on a Linux operating system, you need to connect the hard disk to a Windows computer. When you start the program, it will display all hard disks connected to this computer. In the window that opens, right-click on the disk where the mail client user data was stored and select Open. After that, choose the scan type - Fast scan or Full analysis.

Run a fast scan first - it will take less time. If the program can’t find the missing files, then go for Full analysis, select the file system and click Next. When the scan is complete, follow the path to the directory containing user files, select that folder and click Recovery; choose where to save the data, the hard disk and folder, and hit Recovery again.

After that, the last step is to replace the new user files with the old items like I have shown before. When you do it, you will see all recovered messages in your Inbox folder.

If the program failed to restore access to the user profile and the messages are still inaccessible, you can view them in a text editor.

To do it, open the inbox file. Follow this path:

home/user name/.thunderbird/user directory/mail/mail.hetmansoftware.com

File– Inbox. It contains all emails that were delivered to your mailbox. This way, you’ll be able to receive a necessary email or view the contents of an important message. If this recovery method doesn’t work, try recovering data from the server.

Postfix+Dovecot mail backup

In one of the previous articles, we have already told you about installing and configuring a Postfix server with Dovecot, and where to find email files.

Depending on the type of storage method applied, such files can be stored in the folder with the name var/mail and the user name, if mbox is used.

Alternatively, they can be stored in the folder with the name maildir, if this type of storage method is used. The upper level of Maildir directory contains such folders as Maildir/cur, Maildir/new and Maildir/tmp.

When an email is delivered, it is placed into a file stored inside the tmp subdirectory. The file name is formed with the use of current time, host name, process identifier for the process that created this file, and a random digit - all of these to ensure that all file names are unique.

After the email is written to the file, a link to it is created in the new directory, while the current link is removed from the tmpdirectory.

When the mail client find a message in the new folder, it moves them to the cur folder (with the help of rename(), because otherwise it may result in creating duplicates), while adding informative suffixes to their names. An informative suffix contains a colon (to separate the unique file name and the current information), the digit 2, a comma and various flags. This specific digit - 2 - indicates the version of the information given after the comma. The specification determines the flags used to indicate if the message was read, deleted and so on, and they use the first letters of the following words: Passed, Replied, Seen, Trashed, Draft and Flagged.

So new emails are sent to the new folder, and after they are read, they are passed to the cur folder by renaming them and adding a suffix.

To back up mail files, open the directory for a specific user and copy the message files to another disk.

How to recover emails from backup

To recover emails from a backup you need to transfer the email files from the backup to the new folder following this path – home/user name/Maildir/new.

Immediately after the transfer, you won’t see the messages in the client window, since some changes must be made before it’s possible. To have the files displayed in the mail client, you need to edit their names.

Right-click on a file and choose Rename. Now remove all characters after the domain name of your server. In my case, they are :2,S (colon - two - s).

After that, open the mail client and click Get Messages. After that all the emails that were transferred from backup will appear on the inbox list with the unread status.

This way, you can use files from backup to recover an accidentally deleted email, or transfer emails to the new server.

How to recover email files with Hetman Partition Recovery

If the server breaks down, a user is deleted accidentally, the hard disk is formatted, the operating system is reinstalled, or email files are lost while there is no backup, they can still be restored with the help of Hetman Partition Recovery.

If your server is running on a Linux operating system, you need to take the hard disk out of the server and connect it to a Windows computer. Then start the program and scan the connected disk. After that, follow the path where the email files were stored, select the directory or its contents and click Recovery. Then change the disk and folder where the files should be saved, and click Recovery one more time.

When saving them, the program will ask you to change file names since they contain a colon which is not supported as a filename element by some operating systems, including Windows. In this case, there is nothing to worry about: in the end, the files will be renamed anyway when copied to the server, and those characters will be removed. Check the box next to Replace all unknown symbols to and click to rename them.

After the recovery, the folder will contain email files, and then you can transfer them to a new server.

Before copying the files, the server should be configured, and a user with the same name should be created. Copy the files to the new folder and edit the names as I have shown before - by removing the suffixes containing several characters – *_2,S. After that, open the mail client and check the mail, then click here to get messages. We have recovered all messages.

Conclusion

If for some reason a user permanently loses access to their Thunderbird profile (or their profile in any other mail client), the contents of such files can be viewed in a text editor. As you open it, you’ll see the original email contents, including the sender’s and recipient’s email addresses, text and other data. This way, you’ll be able to retrieve the required information from the recovered emails.

Author: , Technical Writer

Vladimir Artiukh is a technical writer for Hetman Software, as well as the voice and face of their English-speaking YouTube channel, Hetman Software: Data Recovery for Windows. He handles tutorials, how-tos, and detailed reviews on how the company’s tools work with all kinds of data storage devices.

Editor: , Technical Writer

Oleg Afonin is an expert in mobile forensics, data recovery and computer systems. He often attends large data security conferences, and writes several blogs for such resources as xaker.ru, Elcomsoft and Habr. In addition to his online activities, Oleg’s articles are also published in professional magazines. Also, Oleg Afonin is the co-author of a well-known book, Mobile Forensics - Advanced Investigative Strategies.

Recommended For You