• DE
  • EN
  • ES
  • NL

Blog

Fixing a corrupted Thunderbird popstate.dat file


This article originally appeared on the Magentron blog as Fixing a corrupted Thunderbird popstate.dat file.

Posted on Tuesday, October 11th, 2011 by Jeroen Derks.

Update 2013/Mar/18: released v1.2: added support for use of CRLF line endings communicating with server (for e.g. hotmail)

It does not happen often, but sometimes my computer crashes. Unfortunately, but such is the live of a computer user. Most programs and their data are fine after, however, Thunderbird is not one of those. Sometimes after the crash, the popstate.dat file is either corrupted, empty or missing. See also Thunderbird bug #263142

This causes Thunderbird to retrieve all the email messages that were kept at the server to be downloaded again. After another one of those incidents I decided to try and find a work-around for it. Luckily the format of the popstate.dat file is pretty straightforward. Retrieving the UIDL list for the emails stored at the server is key to the solution.

To make things easy, I have written a simple PHP script that will rebuild Thunderbird's popstate.dat file based on the emails stored at the server. Usage is pretty straightfoward.

usage: rebuild_popstate.php [-c] [-d] [-i n] [-s] [-v] [-f file] server [ port ]
          -c CRLF flag, use when talking to Windows servers
          -d debug flag
          -f output filename
          -i ignore the last n messages (for if you don't have them yet)
          -s use for secure POP3 (SSL/TLS)
          -v verbose flag

You can find the script at github: rebuild_thunderbird_popstate

I hope it helps, and if so it would be nice if you could share your experiences here, thanks!

Need help with PHP, Magento or Laravel? Feel free to get in touch.