use strict; use Net::IMAP::Simple; use Number::Format; my $fmt = new Number::Format; # Create the object my $imap = Net::IMAP::Simple->new('yourisp') || die "Unable to connect to IMAP: $Net::IMAP::Simple::errstr\n"; # Log on if(!$imap->login('loluser', 'secretpassword')){ print STDERR "Login failed: " . $imap->errstr . "\n"; exit(64); } # Print the subject's of all the messages in the INBOX my $nm = $imap->select('INBOX'); my $total = 0; for my $i ( 1 .. $nm ) { my $size = $imap->list($i); print "", ($imap->seen($i) ? "* " : " "), $fmt->format_bytes($size, 1), " bytes\n"; $total += $size; } $imap->quit; print "\n total = ", $fmt->format_bytes($total, 1), " bytes\n";