From MozillaZine Knowledge Base

This article was written for Thunderbird but also applies to SeaMonkey (though some menu sequences may differ).

popstate.dat is a file in the Mail folder of a POP account. It stores the state of messages that Thunderbird has downloaded and left on the POP server.


The purpose of popstate.dat

The file records the information that Thunderbird needs to implement the following choices in your account settings for the POP server:

  • Fetch headers only
  • Leave messages on server
  • For at most ... days
  • Until I delete or move them from Inbox

Messages that are downloaded as headers-only are known as truncated messages.

The file is designed to be used by Thunderbird internally, not for users to edit. Even so, you can edit or delete the file to achieve certain results:

  • Download the full text of certain truncated messages
  • Keep certain messages on the server
  • Delete certain messages from the server
  • Prevent the deletion of certain messages from the server
  • Recover messages that you deleted by mistake

Finding popstate.dat

To find the file, open Thunderbird's Account Settings. Go to the account that you want to work with, then to that account's Server Settings page. Look at the Local Directory field (at the bottom of the window pane, next to a browse button) to see the location of the popstate.dat file for the account. Use Windows Explorer (or your operating systems equivalent) to go to that directory.

If the Local Directory setting is not visible see Dialog too small or too large

Deleting popstate.dat

If you delete the file, then Thunderbird has no record of messages that it has downloaded. Normally you only do this if the file is corrupted and you keep getting duplicate messages when checking for new mail. The downside is the next time you get mail for the account, Thunderbird will download all the messages on the server (one last time). You could avoid downloading the messages again if you edited each messages status in popstate.dat but that usually is more work than its worth.

If you are using Windows 7 rather than deleting a corrupt popstate.dat file see if you can restore a recent version of it. That would download far fewer messages than if you delete the file. If you're not using Windows 7 see if you have a recent backup of your profile. You could copy that popstate.dat file over the existing one.

Hacking popstate.dat (Advanced)

Before you hack the file, ensure that Thunderbird is not in the process of getting mail for the account, and that it will not automatically get mail for the account after a certain time interval. You might need to change your account settings to make sure of this.

You do not need to close Thunderbird, but you can if you prefer.

To hack the file, first identify the messages that you want to change (unless you want to change all the messages). Then find the right file for the account, edit it and save it. Immediately get mail for the account to make your changes take effect.

The following sections describe these steps in more detail.

Message states

The file identifies a state for each message that Thunderbird has downloaded and left on the POP server. Each state specifies what Thunderbird will do with the message the next time it gets mail from the POP server. The states are:

Flag Applies to Action
btruncatedDo nothing.
ftruncatedDownload message in full.
kfullKeep message on server.
dfullDelete message from the server.

When a message does not appear in the file at all, then its state is unspecified. This normally means that the message has been downloaded and deleted from the POP server. However, if you remove a message from the file and it does exist on the server, then Thunderbird will download the message again.

You can change the message states manually, as described in the next section.

Note:  The file also contains a time stamp for each message, in a numeric format. Thunderbird uses the time stamp to decide when to delete old messages from the server, if you have specified that in the account settings.

Identifying messages to act on

To identify a message manually:

  1. Select the message in any of the account's folders—for example, the Inbox.
  2. From the menu bar, choose View – Message Source (or press Ctrl-U).
  3. Look for the X-UIDL header near the top of the message source.
  4. Note the value of the UIDL. (In most cases you only need to note the last few characters.)

Example:  The message headers look like this:

From - Mon Jan 01 09:00:00 2007
X-Account-Key: account10
X-Mozilla-Status: 0401
X-Mozilla-Status2: 00000000

You note the value APaxktkAACMqRZj0Jw8jZjL3J7E (but in most cases you only need to note the last few characters: ...3J7E


  • If you plan to download a message from the server again, delete the original message in Thunderbird, to avoid duplicate messages.
  • If a message has no UIDL, then it normally does not exist on the server because when Thunderbird downloaded the message, it immediately deleted the server's copy.
  • The message's time stamp in the file corresponds to the date and time in the From - line at the top of the message source.

Editing popstate.dat

You can edit the file using any text editor. Ensure that the editor you use saves the file as plain text, not in any wordprocessing format.

You do not need to exit Thunderbird before editing this file.

Here are some techniques that you can use:

Download the full text of a truncated message
Change the message's state to f
Keep a message on the server
Change the message's state to k
Delete a message from the server
Change the message's state to d
Prevent the deletion of a message from the server
Change the message's state to k for a full message or b for a truncated message.
Recover a message that you deleted by mistake
Remove the message's entry from the file.

After you edit the file, save it and immediately get mail for the account. Thunderbird processes the actions that you have specified.


  • If you do not get mail immediately after editing the file, then Thunderbird might change some of the actions you specified. For example, if you delete a message before getting mail, then Thunderbird might ignore the action you speciied and delete the message from the server.
  • Avoid duplicate messages. If you plan to download a message again, delete the original before you edit the file. If you discover a duplicate message, delete one copy. Edit the file again if you want to prevent the deletion from affecting the server's copy.