Subject: | Oddness in Mail::IMAPClient |
Date: | Tue, 22 Jan 2008 17:07:21 -0600 |
To: | bug-Mail-IMAPClient [...] rt.cpan.org |
From: | Mike Eggleston <mikee [...] pointwise.com> |
I have a script (inline below) that did run fine, then something changed and I get errors
when I run the script. The script still works (I removed the error printing lines), but
I still get an error with two user accounts. When I run this script I hit the first user
account (of two that generate the error) and the output is:
[cyrus@elo dgarlisch]$ !time
time /opt/pwi/bin/cyrus-expunge.pl -v ; date
Deep recursion on subroutine "Mail::IMAPClient::Massage" at /usr/lib/perl5/site_perl/5.8.8/Mail/IMAPClient.pm line 1818.
Deep recursion on subroutine "Mail::IMAPClient::status" at /usr/lib/perl5/site_perl/5.8.8/Mail/IMAPClient.pm line 2718.
Out of memory!
Any idea what's happening or how I fix this? I currently have a line in the code to
skip around these two accounts. I don't understand what is different about the accounts
that is causing a problem. Both accounts are new (in the last month or so) and have
almost nothing in them.
Mike
P.S.
I just updated to version 'Mail-IMAPClient-3.03-MC9xib'. I'm going to run the script
again before I send this mail to you.
Well, the script worked with the updated module. I'm sending you this email anyway
on the off chance tie error or the script below may be of some use to you.
------------------------------------------ cyrus-expunge.pl start
#!/usr/bin/perl
#$Id: cyrus_expunge.pl,v 19991216.3 2003/06/12 21:38:31 dkernen Exp $
# modified by mikee for the pointwise environment
use Mail::IMAPClient;
use IO::File;
use Getopt::Std;
# parse the command line
our($opt_v, $opt_s) = (0, 0);
getopts('sv') or die "usage: $0 [-v]";
$opt_s = 1 if $opt_v;
$| = 1;
my $start = time;
# Change the following line (or replace it with something better):
my($h, $u, $p) = ('imap.pointwise.com', 'cyrus','cyrus');
my $imap = Mail::IMAPClient->new(
Server => "$h", # imap host
User => "$u", # $u,
Password=> "$p", # $p,
Uid => 1, # True value
Port => 143, # Cyrus
Buffer => 4096*100, # True value
Fast_io => 1, # True value
Timeout => 30, # True value
Debug => 0, # True value
#Debug_fh=> IO::File->new('>/tmp/imap.out'), # must be a fhandle
) or die "$@";
our($folder, $cnt, $purged) = ('', 0, 0);
our($nfolders, $nmessages, $nremoved) = (0, 0, 0);
for my $f ( $imap->folders ) {
$folder = $f;
$nfolders++;
undef $@;
undef $_;
next unless $f =~ /dgarlisch/oi;
#next if $f =~ /dgarlisch|rdennis/oi;
$imap->setacl($f, $u, 'lrswipcda') or print "$0: Cannot setacl for $f: $@\n" and next;
unless ($imap->select($f) ) {
$imap->setacl($f, $u, 'lrswipcda') or print "$0: Cannot setacl for $f: $@\n" and next;
$imap->select($f) or print "$0: Cannot select $f: $@\n" and next;
}
my $messages_before = $imap->message_count($f);
if(defined($messages_before)) {
$imap->expunge;
$imap->close or print "$0: Could not close: $@\n";
$imap->select($f) or print "$0: Cannot select $f: $@\n" and next;
my $messages_after = $imap->message_count($f);
$cnt = $messages_before > $messages_after ? $messages_before : $messages_after;
$purged = $messages_before - $messages_after;
$nmessages += $cnt;
$nremoved += $purged;
} else {
$cnt = $purged = -1;
}
write if $opt_v;
}
# write a summary
if($opt_s) {
my $stop = time;
print "\nSummary:\n";
print "Elapsed Seconds: ", ($stop - $start), "\n";
print "Total Folders: $nfolders\n";
print "Total Messages: $nmessages\n";
print "Total Removed: $nremoved\n";
}
format STDOUT =
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @>>>> @>>>>>
$folder, $cnt, $purged
.
format STDOUT_TOP =
Folder Count Purged
--------------------------------------------------------- ----- ------
.
------------------------------------------ cyrus-expunge.pl end