I'm trying to build a simple imap mail reader, but for some reason, I cannot get the $imap->messages method to work. Any help would be greatly appreciated. And Happy New Year!

Here is the code (with username, password and host changed):

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";

And here is the output

C:\>"C:\Documents and Settings\rsh\My Documents\myperl\imap\imaptest.p +l" 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 li +ne 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 IMAP4R +EV1 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 BINA +RY UNSELECT SCAN SORT THREAD=REFERENCES THREAD=ORDEREDSUBJECT MULTIAP +PEND] 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:\>

Edited by Chady -- fixed formatting, added code tags.


In reply to Mail::IMAPClient wont get messages by RichardH

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.