Install mutt on macOS with home brew [Thursday, 14 October 2021 13:04 PDT]
	      brew install mutt
My Current Mutt on my macOS
	      Mutt 2.1.3 (2021-09-10)
	      System: Darwin 20.6.0 (x86_64)

	      Apple clang version 12.0.5 (clang-1205.0.22.9)
How to set up Mutt for Gmail Account
mutt is Command line IMAP/POP email client. If you manage many emails and love Command Line, then mutt is excellent tool for you. But how easy to setup for your Gmail account
Here are the steps that I used to setup for my Gmail account
Let's dive into the steps how to setup Mutt with Gmail 1. Change Gmail Setting to support IMAP and POP 2. brew install mutt [mutt 1.6] on Mac OSX. If you don't see any error, you are good to go

muttrc file
You need to jump through more hoops
If you still have trouble to connect to Gmail Server, then check Sign-in and security on your Gmail Account

Compile Mutt 1.8 with IMAP, POP and SMTP
Thu Sep 15 12:48:13 PDT 2016 Today I try to download Mutt 1.8 and try it out since there is some issue with Mutt 1.7 that I use currently. The main screen of Mutt is frozen when computer is idle I download the source code run: ./configure, make and make install It seems to be very smooth, there is no error. I ran 'mutt -v' to confirm the version is 1.8 I have my old mutt 1.7 and the ~/.muttrc file in my home directory and I assume I don't need to change any sth on my configure file I hold my breath and run 'mutt' Unfortunately it turns out to be not very smooth. There is error message that I have never seen it before Error: imap_user variable is unknown I used the older version than 1.7 before and I have similar error about IMAP I ran 'mutt -v' again and found out IMAP, POP and SMTP are not enabled by default. Obviously the next question is how to enable them. I try Google it around and see whether I find the answer and I have no luck after a few minutes. I decide to take a look at the configure file and see I can find any clue. Eventually I found out ./configure is accepted arguments which are the flags that enable/disable IMAP, POP and SMTP etc. after I run ./configure --enable-pop --enable-imap --enable-smtp and I run mutt again, I found there is another errors says the ssl and sasl are not enabled here is the final configure options
              ./configure  '--enable-hcache' '--with-sasl=yes' '--enable-pop'   '--enable-imap' '--enable-smtp'
	      '--with-ssl=/opt/local'  '--with-libiconv-prefix=/opt/local' '--with-curses=/opt/local'
It works on my Mac OSX El Capitan[10.11.4] finally Also you need to change smtp_user to the following. The previous port number is 587 with smtp in Mutt 1.7 set smtp_url = 'smtps://' Here are the steps to build mutt with IMAP, POP, SMTP, SSL and SASL 1 download the source code mutt 1.8 2 unzip it and cd to your root directory 3 run: ./configure '--enable-hcache' '--with-sasl=yes' '--enable-pop' '--enable-imap' '--enable-smtp' '--with-ssl=/opt/local' '--with-libiconv-prefix=/opt/local' '--with-curses=/opt/local' 4 done

Go to your Gmail Account setting and enable POP and IMAP
run Mutt -v
Make sure USE_POP USE_IMAP USE_SMTP are enabled
e.g. +USE_POP +USE_IMAP +USE_SMTP are good

If '-USE_POP -USE_IMAP -USE_SMTP' is shown, then you need to enable it
My Own MacOS and Old Mutt
	      mutt -v  (mutt 1.6 on Mac OSX)
Mutt Use Encrypted file for your Gmail Account
1. First to create a file to store your Gmail password under ~/.mutt/ We can create a file ~/.mutt/passwords 2. Add the following to ~/.mutt/passwords
	      set imap_pass="gmail_password"
	      set smtp_pass="gmail_password"
Use gpg to generate public/private key to encrypt your file
	      gpg --gen-key
Encrypt ~/.mutt/passwords with your private key
	      gpg -r -e ~/.mutt/passwords
	      ls ~/.mutt/passwords*
	      /home/user/.mutt/passwords /home/user/.mutt/passwords.gpg
	      rm -P /home/user/.mutt/passwords
Add ~/.mutt/passwords.gpg to your ~/.mutt/muttrc
	      source "gpg -d ~/.mutt/passwords.gpg |"
Final muttrc file
	     # ================  IMAP ====================
	     source "gpg -d ~/.mutt/passwords.gpg |"
	     set imap_user =
	     # set imap_pass =  gmail_password
	     set spoolfile = imaps://
	     set folder = imaps://
	     set record="imaps://[Gmail]/Sent Mail"
	     set postponed="imaps://[Gmail]/Drafts"
	     set mbox="imaps://[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://"
	     # set smtp_pass = $imap_pass
	     set ssl_force_tls = yes # Require encrypted connection
	     set smtp_authenticators = 'gssapi:login'

	     # ================  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        # otherwise name@localhost is used
	     set realname = "name"
	     set from = ""
	     set use_from = yes