Parsing mailboxes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cmika@-takethisout-25thandclement.com

    Parsing mailboxes

    Problem: Mozilla mailbox is way to big (800MBs).
    Solution: Split it up.

    #!/usr/bin/perl

    ############
    # Splits Mozilla style Inboxes into smaller ones (max size = maxMailboxSize)
    # use: ./splitMozilla <mailbox name>
    # output: mailbox0 [mailbox1] [mailbox2] ...
    ############

    $maxMailboxSize = 104857600;
    $mailboxNumber = 0;
    open OUTPUTFILE, ">mailbox$mailb oxNumber";

    while(<>) {
    if(/^From /) {
    if((stat(OUTPUT FILE))[7] > $maxMailboxSize ) {
    close OUTPUTFILE;
    $mailboxNumber ++;
    open OUTPUTFILE, ">Inbox$mailbox Number";
    }
    }
    print OUTPUTFILE $_;
    }

    Problem: It's not working. It's creating mailbox0, writes about 1.9MBs, then
    the system runs out of memory, which shouldn't happen. What I'm basically
    trying to do is search for a new message, check if the outputfile is over
    100MBs, if it is, create a new one, if it's not, then write the message to
    outputfile. Any ideas?

    -Chris Mika
    cmika@-takethisout-25thandclement. com
  • Steve Bennett

    #2
    Re: Parsing mailboxes

    Have you taken into consideration the summary file?
    This is from my netscape knowledge but I assume mozilla is the same.
    If you change a mail folder you have to first kill netscape (mozilla)
    delete the coresponding .summary file and let netscape (mozilla)
    re-create
    the summary file when it starts again.
    The summary files are hidden use ls -al to see them. (in the unix world)

    -s

    cmika@-takethisout-25thandclement. com wrote:[color=blue]
    >
    > Problem: Mozilla mailbox is way to big (800MBs).
    > Solution: Split it up.
    >
    > #!/usr/bin/perl
    >
    > ############
    > # Splits Mozilla style Inboxes into smaller ones (max size = maxMailboxSize)
    > # use: ./splitMozilla <mailbox name>
    > # output: mailbox0 [mailbox1] [mailbox2] ...
    > ############
    >
    > $maxMailboxSize = 104857600;
    > $mailboxNumber = 0;
    > open OUTPUTFILE, ">mailbox$mailb oxNumber";
    >
    > while(<>) {
    > if(/^From /) {
    > if((stat(OUTPUT FILE))[7] > $maxMailboxSize ) {
    > close OUTPUTFILE;
    > $mailboxNumber ++;
    > open OUTPUTFILE, ">Inbox$mailbox Number";
    > }
    > }
    > print OUTPUTFILE $_;
    > }
    >
    > Problem: It's not working. It's creating mailbox0, writes about 1.9MBs, then
    > the system runs out of memory, which shouldn't happen. What I'm basically
    > trying to do is search for a new message, check if the outputfile is over
    > 100MBs, if it is, create a new one, if it's not, then write the message to
    > outputfile. Any ideas?
    >
    > -Chris Mika
    > cmika@-takethisout-25thandclement. com[/color]

    Comment

    Working...