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; \
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: , , , , ,