Friday, January 01, 2010

Open mbox file in Thunderbird

Unfortunately, there seems to be no straightforward way to ask Thunderbird to open or import an Mbox mail file directly.

Say you have an mbox file, and would like to view it in Thunderbird. For this example, we will view the file in a "temp-mbox" folder under Thunderbird's "Local Folders". The convoluted way which seems to work goes like this:

  • In Thunderbird, under Local Folders, create the new "temp-mbox" folder.
  • Exit Thunderbird.
  • Find your "Local Folders" directory in your profile. It may be something like "~/.thunderbird/random-string.default/Mail/Local Folders/". In there, you will find a temp-mbox and a temp-mbox.msf file.
  • Overwrite temp-mbox with your mbox file,
  • and delete the temp-mbox.msf index file.
  • Re-open Thunderbird
I needed to do this, because of another limitation of Thunderbird: it's poor search capabilities. Since the mails I wanted to group are on my own IMAP server, I did the search there, and put all the mails into a single file. What I wanted is all the last year's emails received from or sent to somedomain. The following got me a suitable mbox file:
mbox=somedomain-2009.mbox; search=@somedomain; \
find ~/Maildir/cur ~/Maildir/.Sent/cur -mtime -365 | \
while read f ; do \
if egrep "^(From|To|Cc):.*$search" "$f"; then \
  echo "From - " >>$mbox; \
  cat "$f" >>$mbox; \
fi; \
done
To achieve this using the TB search, I would have needed to:
  • Search Inbox without subfolders for "From contains @somedomain" or "To contains @somedomain" or "Cc contains @somedomain". This also searches previous years, and takes quite a while on my IMAP folder.
  • Save the search
  • Search Sent for "To contains @somedomain" or "Cc contains @somedomain".
  • Save the search
  • Create a folder for results
  • Open the first saved search folders, sort by date, and copy the 2009 mails to the new results folder
  • Repeat with the second saved search.

Labels: , , , , ,

4 Comments:

Anonymous Anonymous said...

Thanks for the awesome tip!

09 January, 2012 23:41  
Anonymous Sandesh Jagdale said...

While opening an mailbox file from Thunderbird 15.0, it is not necessary to delete the .msf file. In fact in my case, when I deleted the .msf file, Thunderbird 15.0 refused to start at all.

In my case I had a compacted 'Archive' Local sub-folder, under the Local Folders in Thunderbird, which created an 'Archive' mailbox file in my 'Local Folders' location.

So to re-open it, I had to create a 'Archive' sub-folder (i.e. same name as your mailbox file) under 'Local Folders' and then just had to replace the 'Archive' file created in 'Local Folders' location, with my mailbox file and Thunderbird was able to show me all the messages within the compacted mailbox, once I restarted Thunderbird.

13 September, 2012 06:38  
Blogger ab1jx said...

If you put the mbox files in a subdirectory of Local Folders this doesn't work. It tries to index the subdirectory. Put the mbox files in the root of Local Folders, let it index them, close Thunderbird, move them into directories, start it up again and all is right.

I downloaded some mbox files from lists.gnu.org by ftp and wanted them in folders by group. I had to index them then move them.

21 December, 2012 05:54  
Anonymous Anonymous said...

Thanks for the tip!

28 July, 2013 12:07  

Post a Comment

Links to this post:

Create a Link

<< Home