More actions
The Old Way
To connect to a server using just plain old telnet and IMAP you would run the following command.
telnet mail.example.com 143
However, you're not going to get very far. Dovecote will not allow an insecure login so you're pretty much dead in the water.
Using OpenSSL to Connect Securely
Luckily, you can get around this by using the wonderful openssl
tool/library to wrap your telnet session in a warm security blanket weaved from the finest encryption the transport security layer has to offer.
- To connect to a mail server using
openssl
:
openssl s_client -connect mail.example.com:143 -starttls imap -no_ssl3
- Once you've established a secure connection with the mail server you should be clear to log into Dovecote:
a login YOUR_EMAIL_ADDRESS YOUR_PASSWORD
- Once you're logged into the Inbox you'll want to see what namespace you're in (AKA where everything is):
n namespace
- Result,
* NAMESPACE (("" ".")) NIL NIL n OK Namespace completed (0.001 + 0.000 secs).
- To list the folders:
A1 list "" "*"
- Results,
* LIST (\HasNoChildren \UnMarked) "." Junk * LIST (\HasNoChildren \UnMarked) "." INBOX.Trash * LIST (\HasNoChildren \UnMarked) "." INBOX.Junk * LIST (\HasNoChildren \UnMarked) "." INBOX.Sent * LIST (\HasNoChildren \UnMarked) "." INBOX.Drafts * LIST (\HasChildren) "." INBOX A1 OK List completed (0.001 + 0.000 secs).
- To select the Inbox:
g21 SELECT "INBOX"
- Results,
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft) * OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted. * 14 EXISTS * 0 RECENT * OK [UIDVALIDITY 1579611755] UIDs valid * OK [UIDNEXT 15] Predicted next UID * OK [HIGHESTMODSEQ 45] Highest g21 OK [READ-WRITE] Select completed (0.001 + 0.000 secs).
- To list the basic information of the top four messages in the Inbox:
f fetch 1:4 (BODY[HEADER.FIELDS (from to subject date)])
- Read the whole second message in the Inbox message:
F1 fetch 2 RFC822
Sources:
https://www.atmail.com/blog/imap-101-manual-imap-sessions/
https://hostpapasupport.com/view-send-email-using-telnet/
https://busylog.net/imap-telnet-example-test-imap-with-telnet/
https://michlstechblog.info/blog/mail-connect-tls-encrypted-to-a-smtp-server-by-telnet/