Mutt is a powerful text email client that can be used to access Gmail over IMAPS. Here are the relevant settings for your .muttrc.

Enable header caching

set header_cache=~/.mutt_cache

Configure IMAP over SSL

set from="FNAME LNAME <USERNAME@gmail.com>"
set imap_user=USERNAME@gmail.com
set imap_pass=PASSWORD
set folder=imaps://imap.gmail.com
set spoolfile=imaps://imap.gmail.com/INBOX
set record=imaps://imap.gmail.com/Sent
set postponed=imaps://imap.gmail.com/Drafts
set timeout=10
set mail_check=5
mailboxes =INBOX

You can connect to a socket using Bash by using exec and redirecting to and from the pseudo-path /dev/tcp/<hostname>/<port> or /dev/udp/<hostname>/<port>. For instance, to connect to your localhost SSH port using TCP:

exec 3<>/dev/tcp/localhost/22

Then, use cat and echo to read or write to the socket. Here is an example read:

cat

Notice that there is no such file as /dev/tcp or /dev/udp. Bash interprets the pseudo-path.