Using mutt – saving password and writing mail in markdown

If I were to be forced to replace my mutt with some other general purpose email client I’d prefer thunderbird with plugin muttator.

If you prefer easy to setup and click-based tools then you will not find mutt very exciting, however those who loves to split hair and tweak their tools to their whims will find much in mutt to please them. Learning the full power of mutt takes time and some sort of persistence. This post is not intended for first time user. It is meant for those who have tried their hands on mutt. In the end, there are some link which can help who wants to start using mutt. I had the fleeting temptation to combine my scripts in one which can set up mutt automatically for arbitrary no of accounts, but then it beats the whole purpose of tweaking the tool.

Storing password

Mutt stores password in plain text format. To avoid this, I used gpg to encrypt a file in which password are stored. For example, a simple text file is created to store the password.

export EE_NAME="Dilawar Singh"
export EE_USER=dilawar
export EE_PASS=password1

This has export command which set an environment variable. Now I encrypt the file using gpg

gpd -c password.txt

It will ask for a pass-phrase. When decrypting the file, you have provide the same pass-phrase. Passphrase are easy to remember and hard to crack. If I were Gabbar Singh, I would have chose something like thakur a per katne chahiye the. Hard to guess and easy to remember, isn’t it? An encrypted file will be created by gpg default name password.txt.gpg. Mutt can read environment variables, let’s exploit this fact. We write a wrapper around the mutt command. Let’s name this script my_mutt or after the name of your pet doggie. And chmod +x my_mutt so it is executable. Store it somewhere like /usr/local/bin.

pwds=`gpg -d ~/.mutt/password.txt.gpg`
eval $pwds
mutt -F ~/.mutt/mutt_server "$@"

Second line decrypt the encrypted file, text of the file is stored in pwds variable and this text is executed by eval command. The environment variables are set. We invoke mutt in this shell so that it can access environment variables EE_USER, EE_PASS etc. On line 4, -F ~/.mutt/mutt_server says that this file is my config file which mutt must read. The default configuration file is ~/.muttrc.

In the configuration file, write something like this. You need to write some more to setup mutt. This is only fragment which is relevant to one account.

# ~/Scripts/mutt/ee
set from="$EE_NAME $"
set hostname="imaps://"
set folder="imaps://"
set imap_user="$EE_USER"
set imap_pass="$EE_PASS"
set record="+mail/Sent"
set postponed="=Drafts"
set spoolfile="imaps://"
set signature="sign.txt"
set smtp_url="smtp://$"
set stmp_pass="$GPO_PASS"
set realname="$REAL_NAME"
my_hdr Organization: EE, IIT Bombay,

In my personal opinion, this is a good solution to store password on machine unless someone has a better solution which does not involve using a green lantern, nanobots or ability of code-bending.

Writing HTML emails

Mutt works great with text emails. But if you want to write emails for wncc group where code has to be written inline, html can help. See this question for potential solutions. I have also written mine.


  1. Mutt wiki is a good reference guide.
  2. My first mutt
  3. And this terminal lover blog

About Dilawar

Graduate Student at National Center for Biological Sciences, Bangalore.
This entry was posted in NoGuiNoMouseNoProblem, Utility and tagged , . Bookmark the permalink.

One Response to Using mutt – saving password and writing mail in markdown

  1. Pingback: Mutt for (G)mail | My XP Linux

Comments are closed.