use strict; use Mail::IMAPClient; use Data::Dumper; use IO::File; my $imap = Mail::IMAPClient->new( Server => "some.secure.imap.server", User => "someuser", Password => "somepassword", debug => 1, ) or die "Cannot connect: $@"; my $folder = "Inbox"; $imap->exists($folder) or warn "$folder not found: $@\n"; my $msgcount = $imap->message_count($folder); defined($msgcount) or die "Could not message_count: $@\n"; print "msg count = ", $msgcount, "\n"; my @msgs = $imap->messages or die "Could not messages: $@\n"; my $i; foreach $i (@msgs) { print "\$i = $i\n"; } $imap->disconnect or warn "Could not disconnect: $@\n"; #### C:\>"C:\Documents and Settings\rsh\My Documents\myperl\imap\imaptest.pl" Using Mail::IMAPClient version 2.2.9 and perl version 5.8.2 (5.008002) Mail::IMAPClient not using Fast_IO; not available on this platform at C:\Documents and Settings\rsh\My Documents\myperl\imap\imaptest.pl line 5 Read: * OK [CAPABILITY IMAP4REV1 LOGIN-REFERRALS STARTTLS AUTH=LOGIN] somehost IMAP4rev1 2003.339 at Wed, 31 Dec 2003 23:25:17 -0600 (CST) Connect: Received this from readline: 0/OUTPUT/* OK [CAPABILITY IMAP4REV1 LOGIN-REFERRALS STARTTLS AUTH=LOGIN] somehost IMAP4rev1 2003.339 at Wed, 31 Dec 2003 23:25:17 -0600 (CST) Sending literal string in two parts: 1 Login "someuser" {6} then: somepassword Sending: 1 Login "XXXXXX" {6} Sent 36 bytes Read: + Ready for argument Sending: somepassword Sent 8 bytes Read: 1 OK [CAPABILITY IMAP4REV1 IDLE NAMESPACE MAILBOX-REFERRALS BINARY UNSELECT SCAN SORT THREAD=REFERENCES THREAD=ORDEREDSUBJECT MULTIAPPEND] User someuser authenticated Autoloading: STATUS Inbox (MESSAGES) Sending: 2 STATUS Inbox (MESSAGES) Sent 27 bytes Read: * STATUS INBOX (MESSAGES 90) 2 OK STATUS completed Sending: 3 STATUS Inbox (MESSAGES) Sent 27 bytes Read: * STATUS INBOX (MESSAGES 90) 3 OK STATUS completed msg count = 90 Sending: 4 UID SEARCH ALL Sent 18 bytes Read: 4 BAD Command unrecognized: UID SEARCH $i = Sending: 5 LOGOUT Sent 10 bytes Read: * BYE somehost IMAP4rev1 server terminating connection 5 OK LOGOUT completed C:\>