oko1 has asked for the wisdom of the Perl Monks concerning the following question:

Gurus, namaste! :)

I'm trying to set up a browseable archive based on a single 50+MB mailbox. The few apps I've seen that do anything like that generally use techniques from the pre-dawn of history: breaking up the mbox into a gazillion tiny little files and then laboriously creating the "Previous/Next message", "Previous/Next thread" link structure by hacking at the file/directory structure (with an axe, as I recall, but I may be mistaken.)

From the other end, though (i.e., posts here talking about building webmail progs), I'm running into a maze of hypercomplexity. I mean, really - Catalyst? HTML::Mason? A large pile of Mail::* modules? That's more about a big, complete mail app - and all I really want to do is a) index a big mbox, and b) show a nice interface to the users that lets them read the individual emails and walk the structure in a simple, convenient way. Maybe throw in a regex-based search engine, too.

Meanwhile, I'm having a problem coming up with a good approach for this. Load it in a DB and use SQL to query the thing? Build a file of pointers into the file and reindex it every time I add something to the archive? 'tie'? 'dbmopen'? I've chased myself into a corner, here, and can't see a sensible way out. :(

So, does anyone know of such a program (preferably one written in Perl), or have some relatively simple approach to putting this together? I'd really appreciate a helping hand.


--
"Language shapes the way we think, and determines what we can think about."
-- B. L. Whorf

Replies are listed 'Best First'.
Re: Indexing an mbox file
by dHarry (Abbot) on Jan 15, 2010 at 08:02 UTC

    I'm probably missing the point here. 50+MB seems rather small. I have a mail archive over 1 GB and simply use the Thunderbird mail client. I split things up in some 10 directories but this is not necessary. I can easily navigate/search all my mail.

    Cheers

    Harry

      Err, sorry - I guess I didn't make it clear enough! This is supposed to be a Web app.


      --
      "Language shapes the way we think, and determines what we can think about."
      -- B. L. Whorf

        Consider using a different format, like maildir. (There is a 'perfect' converter available at http://perfectmaildir.home-dn.net/, of course written in Perl.) Or make it independant from file formats and use IMAP to access the mailbox.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re: Indexing an mbox file
by Marshall (Canon) on Jan 16, 2010 at 04:19 UTC
    A key thing is that each new message in the MBox format starts with '^From '.

    I often use agrep (approximate grep) for parsing e-mail, but I know that agrep has some defects and doesn't always produce the "right answer". It usually does, but sometimes not. I would be interested if anybody wants to help in a re-coding effort?