Skip to content

Instantly share code, notes, and snippets.

@alexm
Created February 21, 2011 08:51
Show Gist options
  • Save alexm/836824 to your computer and use it in GitHub Desktop.
Save alexm/836824 to your computer and use it in GitHub Desktop.
find all imap folders and print total and new number of messages
#!/usr/bin/perl
use strict;
use warnings;
my $SERVER = 'imap.example.com';
my $USER = 'user.name@example.com';
my $PASSWD = '***';
my $PORT = 993;
my $SSL = 1;
use Mail::IMAPClient qw();
my $imap = Mail::IMAPClient->new(
Server => $SERVER,
User => $USER,
Password => $PASSWD,
Port => $PORT,
Ssl => $SSL,
);
for my $f ( $imap->folders ) {
my $total = $imap->message_count($f);
next unless defined $total;
my $new = $imap->unseen_count($f);
print "$f: $total total, $new new\n";
}
$imap->logout;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment