Parsing mailboxes

Discussion in 'Perl' started by cmika@-takethisout-25thandclement.com, Aug 24, 2004.

  1. Guest

    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$mailboxNumber";

    while(<>) {
    if(/^From /) {
    if((stat(OUTPUTFILE))[7] > $maxMailboxSize) {
    close OUTPUTFILE;
    $mailboxNumber ++;
    open OUTPUTFILE, ">Inbox$mailboxNumber";
    }
    }
    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
     
    , Aug 24, 2004
    #1
    1. Advertising

  2. 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

    wrote:
    >
    > 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$mailboxNumber";
    >
    > while(<>) {
    > if(/^From /) {
    > if((stat(OUTPUTFILE))[7] > $maxMailboxSize) {
    > close OUTPUTFILE;
    > $mailboxNumber ++;
    > open OUTPUTFILE, ">Inbox$mailboxNumber";
    > }
    > }
    > 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
    >
     
    Steve Bennett, Aug 27, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sunil
    Replies:
    3
    Views:
    388
  2. Replies:
    1
    Views:
    421
    christian_harper
    Jul 26, 2006
  3. Grzegorz Adam Hankiewicz
    Replies:
    3
    Views:
    377
    Andrew Dalke
    Jul 13, 2003
  4. Grzegorz Adam Hankiewicz
    Replies:
    0
    Views:
    340
    Grzegorz Adam Hankiewicz
    Jul 26, 2003
  5. foten

    IMAP - get size of mailboxes

    foten, Sep 10, 2004, in forum: Python
    Replies:
    3
    Views:
    1,880
    foten
    Sep 14, 2004
Loading...

Share This Page