To quickly test an imap server using telnet use:
telnet server 143
01 LOGIN username password
02 LIST "" *
03 SELECT mailbox
Line 02 shows you all available mailboxes.
To show the information about a mailbox:
04 STATUS mailbox (MESSAGES)
Between () you can place one or more of the following: MESSAGES, UNSEEN, RECENT UIDNEXT UIDVALIDITY
And one of the following commands to view the a message 1 is the first message * is wildcard for all:
05 FETCH 1 ALL # All IMAP headers
05 FETCH 1 FULL # Full headers and body info
05 FETCH 1 BODY # Body
05 FETCH 1 ENVELOPE # Envelope
05 FETCH * FULL # All email
To fully retrieve a message use:
06 UID fetch 1:1 (UID RFC822.SIZE FLAGS BODY.PEEK[])