Setting up the Mutt mail client with Protonmail

Brian Thompson
5 min readAug 6, 2021

--

Most of the text in the introduction is ripped from Wikipedia.

Mutt is a text-based email client for Unix-like systems. It was originally written by Michael Elkins in 1995 and released under the GNU General Public License version 2 or any later version. The Mutt slogan is “All mail clients suck. This one sucks less.”

Mutt supports most mail storing formats (notably mbox and Maildir) and protocols (POP3, IMAP, etc.). It also includes MIME support, notably full PGP/GPG and S/MIME integration.

Mutt was originally designed as a Mail User Agent (MUA) and relied on the locally accessible mailbox and sendmail infrastructure. According to the Mutt homepage, “though written from scratch, Mutt’s initial interface was based largely on the ELM mail client.” New to Mutt were message scoring and threading capabilities. Later, support for fetching and sending email via various protocols such as POP3, IMAP, and SMTP was added. However, Mutt still relies on external tools for composing and filtering messages.

Mutt has hundreds of configuration directives and commands. It allows for changing all the key bindings and making keyboard macros for complex actions and the colors and layout of most of the interface. Through variants of a concept known as “hooks,” many of its settings can be changed based on criteria such as current mailbox or outgoing message recipients. Mutt supports an optional sidebar, similar to those often found in graphical mail clients. There are also many patches and extensions available that add functionality, such as NNTP support.

Mutt is fully controlled with the keyboard and supports mail conversation threading, meaning one can easily move around long discussions such as in mailing lists. Unlike pine, new messages are composed with an external text editor, which embeds its own editor known as pico.

Mutt can efficiently search mail stores by calling on mail indexing tools such as Notmuch, and many people recommend Mutt be used this way. Alternatively, users can search their mail stores from Mutt by calling grep via a Bash script.

Mutt is often used by security professionals or security-conscious users because of its smaller attack surface than other clients that ship with a web browser rendering engine or a JavaScript interpreter. Concerning Transport Layer Security, Mutt can be configured to trust certificates on first use and not to use older, less secure versions of the TLS protocol.

Requirements

  • The “mutt” package is installed (sudo apt install mutt)
  • A ~/.mutt directory along with a ~/.mutt/muttrc file
  • Other files like ~/.mutt/signature
  • A GPG key
  • You have a protonmail email account
  • You have the Protonmail bridge installed and are logged into it
  • You have the credentials given by the Protonmail bridge ready to go (these are different from your Protonmail account login credentials)

The muttrc file

Most of these settings are fluff and aren’t needed. I took this example from my own mutt configuration. Forgive me if it’s not clean and some options are duplicated. I did my best to clean it up beforehand and remove what I could.

set realname = "FirstName LastName"set pgp_default_key = "<gpg key identifier>"# macrosmacro index gd "<change-folder>$postponed<enter>" "go to drafts"macro index gs "<change-folder>$record<enter>" "go to sent"macro index gi "<change-folder>$spoolfile<Enter>" "go to inbox"macro index gt "<change-folder>$trash<enter>" "go to trash"macro index,pager A "<save-message> =Archive<enter> "archive message"macro index 1 "<change-folder> =../debian/inbox/<enter>"# Use mouse wheelbind pager <down> next-linebind pager <up> previous-line# Don't add a + to urls that wrapunset markers# Don't ask to confirm deletionsset delete = no# Don't move read mail to all mailset move = no# Don't show the help barset help = no#Don't wait to switch mailboxesset sleep_time = 0# Read top-down mail instead of bottom-upset sort = reverse-threads# Simplify UIset status_format = "%f"set date_format = "%m%d"set index_format = "%Z %D %-15.15n %s"# Keep a list of contacts (aliases)set alias_file = ~/.mutt/alias# Import SMTP and IMAP credentialssource "gpg -dq ~/.mutt/protonmail.gpg |"### Pagerignore *unignore From Message-ID Date To Cc Bcc Subjectset pager_stop# Prefer plain text to htmlalternative_order multipart/mixed multipart/related text/plain# Consult mime.types for determining types of attachmentsmime_lookup applications/octet-stream### Message compositionset mime_type_query_command = "xdg-mime query filetype"set sendmail = "/usr/bin/msmtp"### Otherset indent_string = ">"set reflow_wrap = 80set reflow_textunset reflow_space_quotesunset imap_passiveset imap_check_subscribedset mail_check = 15set timeout = 15set sidebar_visisble = noset sidebar_width = 30color sidebar_new brightred defaultmacro index b "<enter-command>toggle sidebar_visible<enter>"macro pager b "<enter-command>toggle sidebar_visible<enter>"unset ssl_use_sslv3unset ssl_use_tlsv1set ssl_verify_datesset ssl_verify_hostset to_chars=" +TCF"push <show-version>auto_view text/htmlset abort_subject = yesset copy = noset pgp_sign_as = "FirstName LastName"set pgp_use_gpg_agentset pgp_timeout = 1800set crypt_autosignset crypt_replysignset crypt_replysignencryptedset check_newset editor = vimset mh_purgeunset confirmappendunset confirmcreateset keep_falggedset save_addressset save_nameset mark_oldset smart_wrapset signature= "~/.mutt/signature"set edit_hdrs

There are two files referenced that we need to set up, ~/.mutt/protonmail.gpg and ~/.mutt/signature. Let’s look at the protonmail.gpg first.

The protonmail file

This file needs to be gpg-signed to use in the .muttrc file. The command for doing so is referenced in “Final steps.” Whenever you make changes to this file, you need to sign in again.

Here is a screenshot of where you would get your Protonmail credentials for mutt:

set starttls = yesset ssl_force_tls = yesset send_charset = "us-ascii:utf-8"set imap_pass = "<protonmail bridge password>"set imap_user = "<protonmail email>"set smtp_url = "smtp://<protonmail email>:<protonmail bridge password>@localhost:1025"set folder = "imap://localhost:1143"set spoolfile = "imap://localhost:1143/INBOX"set postponed = "imap://localhost:1143/[Protonmail]/Drafts"set mbox = "imap://localhost:1143/[Protonmail]/All Mail"set header_cache = "~/.mutt/cache/headers"set message_cachedir = "~/.mutt/cache/bodies"set certificate_file = "~/.mutt/certificates"set smtp_authenticators = "gssapi:login"set imap_keepalive = 900set from = "<protonamil email>"set use_from = yesunset use_domain

The signature file

This can be whatever you want it to be. The signature is inserted at the end of your email under an automatically inserted “ — “ preceding it.

For instance, mine is:

Sincerely,S.E.

Final steps

$ mkdir ~/.mutt/cache$ gpg --sign ~/.mutt/protonmail

--

--

Brian Thompson
Brian Thompson

Written by Brian Thompson

Order yourself, order your house.

No responses yet