Neomutt - TUI Mail client!
Neomutt is a terminal email client that needs some configuration to setup and get started. However despite it's difficult setup, it has a couple of benefits over traditional web email clients. In this blog I'll explain how to setup Neomutt on your system.
Setup
- First we begin by installation. You can use brew on mac
brew install neomutt
On arch, you can use
pacman -Syu neomutt
- Next, we connect to the google IMAP and SMTP server. While POP can be used for offline sync, it's not advisable.
But before we proceed with the configuration, if you have any confusion regarding these different email protocols, you can check out my previous blog post
How to add gmail to NeoMutt
-
Firstly, enable 2-factor Authentication on your gmail account if you haven't already.
-
Next, you need to setup an app password, please do not use your google account password.
- Go to Google Account > Security > App Passwords.
- Generate an App Password for NeoMutt.
- Use that password instead of your actual Gmail password.
-
Enable IMAP in Gmail
- Go to Gmail Settings → See all settings → Forwarding and POP/IMAP.
- Under IMAP access, select Enable IMAP.
- Click Save Changes.
-
Create a folder where your neomuttrc config file is located (
~/.config/neomutt) called accounts. Add a file in it called gmail and put the following template in it:
# vim: filetype=muttrc
unmailboxes *
# in/out mail servers
set imap_pass = "<APP_PASSWORD_HERE>"
set smtp_pass = "<APP_PASSWORD_HERE>"
set realname = "<YOUR_NAME>"
set smtp_url = "smtps://<YOUR_EMAIL_ID>@smtp.gmail.com:587"
set folder = "imaps://<YOUR_EMAIL_ID>@imap.gmail.com:993"
set from = "<YOUR_EMAIL_ID>"
set envelope_from
set use_from = "yes"
# Main Inbox
set spoolfile = "+INBOX"
# Sent Mail
set record = "+[Gmail]/Sent Mail"
# Drafts
set postponed = "+[Gmail]/Drafts"
# Trash (Bin)
set trash = "+[Gmail]/Trash"
# Define Mailboxes (Including Archive & Spam)
mailboxes =INBOX \
="[Gmail]/All Mail" \
="[Gmail]/Sent Mail" \
=[Gmail]/Drafts \
=[Gmail]/Spam \
=[Gmail]/Trash
# Allow Mutt to open a new IMAP connection automatically.
unset imap_passive
# Keep the IMAP connection alive by polling intermittently (time in seconds).
set imap_keepalive = 300
## Hook -- IMPORTANT!
account-hook $folder "set imap_pass=<APP_PASSWORD_HERE>"
- Apply these Settings to your file (I've set it up in above code to work with gmail. For any other provider, you'll have to use the right smtp and imap domains and ports.
warning
Don't put your app password directly. Save it in an encrypted file and import it here.
