While I connect to an SMTP server via telnet regularly, I do it seldom for IMAP servers.
More as a personal note I want to cite what I found on <a href=http://blog.sjas.de/posts/imap-via-linux-shell.html>imap via linux shell</a>
Connect to server:
nc SERVERNAME-OR-IP 143
openssl s_client -connect SERVERNAME-OR-IP:993
enumerate/prefix commands with arbitrary labels or simply a '.' login USERNAME "PASSWORD" # login list "" "*" # show all mailboxes status [mailbox] select "MAILBOX" # switch to mailbox fetch FIRST:LAST FLAGS fetch MAILID BODY[HEADER] fetch MAILID BODY[TEXT] uid search all uid store MAILID +flags (\Deleted) # mark as deleted expunge # actual delete logout # logout