How to read emails in Gmail using IMAP and TELNET/OPENSSL
You can fetch messages from a google mailserver from your console using IMAP
- OK Gimap ready for requests from 129.126.203.226 13mb31937973pjz
The last line gives an OK status and waits for our next step.
## Send login command
When sending communicating with the IMAP server each command must be prefixed with a "tag". This tag will also be used in the response. Login using **<tag> LOGIN <emailAddress> <appPassword>**:
l1 LOGIN user@gmail.com your-app-password
The server responds with an OK and a list of capabilities:
- CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE ENABLE MOVE CONDSTORE ESEARCH UTF8=ACCEPT LIST-EXTENDED LIST-STATUS LITERAL- SPECIAL-USE APPENDLIMIT=35651584 l1 OK user@gmail.com authenticated (Success)
## Select an inbox or folder
Once logged in we can select an inbox or folder to read emails from with the **SELECT** command.
s1 SELECT "INBOX"
The "INBOX" term selects the default gmail inbox. The response is as follows:
xx SELECT "INBOX"
- FLAGS (\Answered \Flagged \Draft \Deleted \Seen $NotJunk $NotPhishing $Phishing NotJunk)
- OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen $NotJunk $NotPhishing $Phishing NotJunk *)] Flags permitted.
- OK [UIDVALIDITY 657432840] UIDs valid.
- 58338 EXISTS
- 0 RECENT
- OK [UIDNEXT 67668] Predicted next UID.
- OK [HIGHESTMODSEQ 8681197] s1 OK [READ-WRITE] INBOX selected. (Success)