#!/usr/bin/perl use strict; use warnings; use Getopt::Long; use Pod::Usage; use Mail::Box::Manager; my $options; GetOptions( 'mail-folder=s' => \$options->{folder}, 'dump-subject=s' => \$options->{dumpfile}, ); pod2usage( -message => "$0: syntax error: pay attention!\n\n", -exitval => 1, -verbose => 1, # Give "Synopsis" and "Arguments" -filehandle => \*STDERR, ) unless( ( $options->{folder} and -d $options->{folder} ) # or # ( $options->{dumpfile} and -f $options->{dumpfile} ) ); my $manager = new Mail::Box::Manager; my $folder; eval{ $folder = $manager->open( folder => $options->{folder}, create => 0, access => 'r', type => 'maildir', expand => 'LAZY', log => 'DEBUG', # adds a lot of noise trace => 'DEBUG', # adds a lot of noise ); }; die "Error opening maildir [$options->{folder}]: '$@'\n\n" if $@; print qq{Folder [} . $folder->name . qq{] aberto com [} . scalar @$folder . qq{] mensagens.\n\n}; if( $options->{dumpfile} ){ open DUMP, '>', $options->{dumpfile} or pod2usage( -message => qq{Can't create dumpfile: $!\n\n}, -exitval => 2, -verbose => 1, -filehandle => \*STDERR ); print( DUMP $_->subject(), $/ ) foreach @$folder; close DUMP or die qq{Can't close(!?!) dumpfile $options->{dumpfile}\n\n}; } # fi eval{ $folder->close }; die "Error closing maildir [".$folder->name."]: '$@'.\n\n" if $@; __END__ =pod =head1 NAME mail-box-test - Simple test to see if Mail::Box::Maildir is working correctly. =head1 SYNOPSIS perl mail-box-test --mail-folder='/path/to/mail/dir/' [--dump-subject=/path/to/subjects.txt] =head1 ARGUMENTS =over 4 =item --mail-folder Points to the maildir you want to use for testing. No maildir means test failure, so please choose a maildir to test. =item --dump-subject Force dumping of subject lines of a maildir to a specified file on the disk. =back =head1 DESCRIPTION This script tests a Mail::Box resource usage under linux for a client. I'm facing a funny problem when trying to open maildirs with more than 21,000 messages in it: Mail::Box is telling me its opening the maildir correctly but no messages are found inside it. =head1 AUTHOR Luis Campos de Carvalho, a.k.a. Monsieur Champs. mailto: monsieur_champs [at] yahoo [dot] com [dot] br =cut