How to set up mutt (text-based mail client) with Gmail?

A step-by-step guide to configure your terminal mail client!

What, When and Why?

Well if you are a beginner like me and have been living in this illusion that we have to open the browser client to send and receive emails then this blog is to tell you that you are not alone!

  1. Or get into some serious Linux Kernel Development kinda business where you are not expected to send HTML emails and base64 attachments. Well to tell you the secret — entire Linux kernel is developed and maintained over emails. So you know now how important an email client becomes 😄
Photo by Michael Dziedzic on Unsplash

The Steps (For Ubuntu 18.04 and above)

Enough of Introduction! Let’s start with the steps!

sudo apt-get install mutt
mkdir -p ~/.mutt/cache/headers
mkdir ~/.mutt/cache/bodies
touch ~/.mutt/certificates
touch ~/.mutt/muttrc
# ================  IMAP ====================
set imap_user = yourusername@gmail.com
set imap_pass = yourpassword
set spoolfile = imaps://imap.gmail.com/INBOX
set folder = imaps://imap.gmail.com/
set record="imaps://imap.gmail.com/[Gmail]/Sent Mail"
set postponed="imaps://imap.gmail.com/[Gmail]/Drafts"
set mbox="imaps://imap.gmail.com/[Gmail]/All Mail"
set header_cache = "~/.mutt/cache/headers"
set message_cachedir = "~/.mutt/cache/bodies"
set certificate_file = "~/.mutt/certificates"
# ================ SMTP ====================
set smtp_url = "smtp://yourusername@smtp.gmail.com:587/"
set smtp_pass = $imap_pass
set ssl_force_tls = yes # Require encrypted connection
# ================ Composition ====================
set editor = "vim" # Set your favourite editor.
set edit_headers = yes # See the headers when editing
set charset = UTF-8 # value of $LANG; also fallback for send_charset
# Sender, email address, and sign-off line must match
unset use_domain # because joe@localhost is just embarrassing
set realname = "Your Name"
set from = "yourusername@gmail.com"
set use_from = yes
Allow less secure apps: ON
mutt
mutt (Pic source: https://www.flickr.com/photos/xmodulo/22809928093)

Getting Started with mutt

Let me help you also send you your first non-HTML email from Terminal to yourself 👈

Recall postponed message? ([yes]/no):

SWE Intern’21@HackerRank | GSoC’21 @CNCF:Buildpacks | CNCF Spring Intern’21 for CNCF: Kubernetes| GSoC ’20@RTEMS | Learner | Poet.