How to configure mutt for gmail

In one article, I have talked about mutt, a text based mail client. Although not as popular as Thunderbird or Evolution, mutt still has the love of many avid Linux users. If you just want to read the text of the emails like me, you should consider using mutt as the default mail client. Mutt is highly customizable and if you want to learn everything about mutt, I recommend you to check the Woodnotes Guide to the Mutt Email Client. However, if you are lazy to read this guide (it's pretty long), this article will show you a simple guide to set up mutt for your email account.

First, you need to install mutt. In Arch Linux, the command will be:
 sudo pacman -S mutt  

In Ubuntu and other Debian-based distro, the command will be:
 sudo apt-get install mutt  

After installing mutt, the next step is to configure it for your gmail. The configuration file will be .muttrc. Use your favorite text editor to create the file .muttrc, I will use vim here:
 vim ~/.muttrc  

Next, just copy and paste the following lines into your .muttrc and you are ready to use mutt ( dont forget to edit the username and password of your gmail):
 # Sets up mail box in your home folder  
 set mbox_type=maildir  
 set mbox="~/mail/inbox/"  
 set spoolfile="~/mail/inbox/"  
 set folder="~/mail/"  
 set record="~/mail/sent/"  
 set postponed="~/mail/postponed/"  
 #Gmail account info  
 set from = ""  
 set realname = "your name"  
 set imap_user = ""  
 set imap_pass = "your gmail password"  
 #My Editor  
 set editor='vim + -c "set textwidth=72" -c "set wrap" -c "set nocp" -c "?^$"'  
 #Remote Folders  
 set folder = "imaps://"  
 set spoolfile = "+INBOX"  
 set postponed ="+[Gmail]/Drafts"  
 #Local Folders  
 set header_cache =~/.mutt/cache/headers  
 set message_cachedir =~/.mutt/cache/bodies  
 set certificate_file =~/.mutt/certificates  
 #SMTP Setup  
 set smtp_url = "smtp://"  
 set smtp_pass = "your gmail password"  
 #Special Keybindings  
 bind editor <space> noop  
 macro index gi "<change-folder>=INBOX<enter>" "Go to inbox"  
 macro index ga "<change-folder>=[Gmail]/All Mail<enter>" "Go to all mail"  
 macro index gs "<change-folder>=[Gmail]/Sent Mail<enter>" "Go to Sent Mail"  
 macro index gd "<change-folder>=[Gmail]/Drafts<enter>" "Go to drafts"  
 #Mutt Session Security  
 set move = no #Stop asking to "move read messages to mbox"!  
 set imap_keepalive = 900  
 # Colors  
 color hdrdefault cyan default  
 color attachment yellow default  
 color header brightyellow default "From: "  
 color header brightyellow default "Subject: "  
 color header brightyellow default "Date: "  
 color quoted green default  
 color quoted1 cyan default  
 color quoted2 green default  
 color quoted3 cyan default  
 color error   red       default     # error messages  
 color message  white      default     # message informational messages  
 color indicator white      red       # indicator for the "current message"  
 color status  white      blue      # status lines in the folder index sed for the mini-help line  
 color tree   red       default     # the "tree" display of threads within the folder index  
 color search  white      blue      # search matches found with search within the internal pager  
 color markers  red       default     # The markers indicate a wrapped line  
 color index   yellow default '~O'  
 color index   yellow default '~N'  
 color index   brightred    default '~F'  # Flagged Messages are important!  
 color index   blue default  '~D'      # Deleted Mails - use dark color as these are already "dealt with"  
 # identifies email addresses  
 color body  brightred black [\-\.+_a-zA-Z0-9]+@[\-\.a-zA-Z0-9]+  
 # identifies URLs  
 color body  brightblue black (https?|ftp)://[\-\.,/%~_:?&=\#a-zA-Z0-9]+  

Save the file then type "mutt" in the terminal and you will have mutt running. Below are the screenshots of my mutt. If you use my .muttrc, you will have the same font and color, if you dont like my color choice, just edit the color part in the configuration file .muttrc

configure mutt

mutt gmail
linux tips and tricks