Threaded and limited


To have a threaded view (emails sorted by thread/author) and only seeing the current thread, combine views and limits:

  • In ~/.muttr add set sort = 'threads' or resort your emails by pressing 'o'.
  • Limit the view

    • Tag all emails in the current conversation: ESC T
    • Apply a limit: ; l
    • Limit to to thread: ~T

Put this in a macro and be happy:

macro index,pager ut <tag-thread><limit>~T<enter><tag-thread> "show only current thread"
macro index,pager ua <limit>all<enter> "show everything"

Run Makro on Startup

The Makro for deleting all the incoming spam runs on the startup by putting it into the alias:

$ alias mutt-c='mutt -F ~/.muttrc-c -e "push <f1>"'

All unwanted emails are pre-selected and ready to be deleted when starting mutt.


Certifacte check failed

I get an error in mutt connecting to the companies exchange server, saying:

Certificate host check failed: certificate owner does not match hostname xyz

For the trusting hosts I know adding a single line in the corresponding .muttrc-file disabled the check:

unset ssl_verify_host



Instead of searching, you can limit (filter) the index list of mutt and display only the messages of a certain interest. Instead '/' use 'l' (lowercase L). Per default it searches for subject, author and sender e-mailaddresses.  If you are in your sent email folder, this does not help you when you want all mails to a certain recipient. I found the following additional parameters quite helpful:

  • ~s party : messages with subject containing "party"
  • ~d * ~t paulm : To: matches paulm (useful for sent-mail folders)
  • ~O : old (i.e. unread but not new) messages. ~N is new unread. ~U is unread, i.e. both together.
  • ~p : messages addressed to you (useful if your inbox is bombarded with mailing list or system report activity).
  • ~p ~U : for messages to you you have not read yet.
  • ~d [MIN]-[MAX]: Filter by date (format mm/dd/yyyy).
  • . : matches everything. In effect, remove the limit.
  • ~h Content-Type:.*html | ~h Content-Type:.*multipart : messages with HTML-attachments | all attachments

More in the mutt-documentation, section 4.2: patterns.

Mark Tagged as read


Switching folders

After a while it is getting quite boring, almost annoying to manually switch between often used folders of a account. Switching between Trash and Inbox and Send can really annoy the shit out of you, if you have to to it too often.

Instead you can assign key-bindings to perform the necessary actions for you when giving just one or two keystrokes:

macro index gi "=INBOX" "Go to inbox"
macro index gs "=INBOX.Sent" "Go to Sent Mail"
macro index gd "=INBOX.Drafts" "Go to drafts"
macro index gt "=INBOX.Trash" "Go to Trash"

On pressing gs (maybe you should press before) mutt switches into the folder for the send mails. Addresses is this folder on IMAP by INBOX.Sent. This might not be correct in your case, but you figure out the right folder address when you switch to the folder manually (hopefully for the last time) and then you will see the current address in the bottom line of mutt.

ELinks (HTML-Emails)

For reading crappy HTML emails inside the interface of mutt, two changes are necessary. Using a .mailcap file you tell mutt to render all HTML mails as text and display them in links or any other console browser you like. If you do not have one already, create a .mailcap file in your home directory and put the following lines in it:

text/html; links %s; nametemplate=%s.html
text/html; links -dump %s; nametemplate=%s.html; copiousoutput

Now tell mutt to automatically render HTML emails by putting this into your .muttrc file:

auto_view text/html

If you get a couple of mails with problems displaying special characters like å, ø , æ. etc, you might consider W3M for the mails instead of links (or ELinks).


I have replaced links with ELinks in ~/.mailcap. Occasionally I get HTML-emails from systems, sending out logs and reports and marking errors with HTML color-tags. Reading them on the console costs much time when you have to try to spot the errors. Of course you could just search within ELinks after terms like "Error", but that is to obvious [^1].

  • You need to configure ELinks to be able to send the current URL to the external browser.
  • You need to configure a short cut for this action within ELinks.

So you do the following to configure ELinks

  • Within ELinks you go to Setup -> Options Manager -> Document -> URI passing.
  • There you add an option with a name like Opera or Firefox.
  • Edit this option and add the parameter for your Browser, e.g. : opera -backgroundtab %c.
  • Save this edit.
  • Within ELinks you got to Setup -> Key-binding Manager -> Main Mapping -> Pass URI of current frame to external command.
  • Add an option for a shortcut, e.g. CTRL-o.
  • Save this edit.

When you now press +o within ELinks your configured browser will open (or just open an additional Tab) and display the HTML document.

This will edit ~/.elinks/elinks.conf and add the following lines (if configured with Opera):

set document.uri_passing.Opera = "opera -backgroundtab %c"
bind "main" "Ctrl-O" = "frame-external-command"


Open files

The small file .mailcap is your key to happy life. Mutt checks that file first to see if an attached file you want to open has been specified there and how to open it. Occasionally you stumble over some files or configurations that do not really work out.

Another experience you might make is that mutt waits until the started application terminates until you can continue using it. So just opening a PDF out of mutt and at the same time checking another file or email does not really work out.

Unless you fork a separate process for it. There are several ways of doing it, but I just implemented a tiny script which I found here to do that for me: And it works fine.

So instead opening an attached jpg-image with gthumb like this:

image/jpg; gthumb %s

I will do it like this instead:

image/jpg; mutt_bgrun gthumb %s

mutt_bgrun needs to be available within the $PATH otherwise it is not gonna be found.

Open in browser


Sometimes badly formatted emails are only readable with a proper HTML parsing technology. You can push any HTML email into a browser in order to view the content there.

Mailcap offers the ability to define an additional command. One for the automatic preview (as mentioned above) and one for the interactive menu. To open a email attachment we can use this interactively.

text/html; firefox %s;
text/html; /usr/bin/w3m -I %{charset} -T text/html -dump; copiousoutput;

The first entry i opening the paramter %s with the browser firefox.

The second command however (the one appeneded with the copiousoutput tag) defines the default behaviour. In this example it will render the content with the console based browser w3m.

To use this in mutt use v to see the attachments, choose the HTML file and press v in order to send it to mailcap. This will open a tab in firefox.

Encrypt Passwords

As known the passwords can be stored directly into the configuration file ~/.muttrc. And as also known this should not be the way to do it, since simple access to this file would grant all access to the whole e-mail folder.

One way to fix this security-issue is to store the passwords encrypted in a GPG file and source it directly into the configuration file. That way Mutt will ask when coming up for a password to decrypt the file. This will not be the password for the e-mail account, but the password for the pgp file. That way no password is stored in plain text on the local disk.

  • Create a text-file with the two parameters for defining the password in it:

    set imap_pass="password"
    set smtp_pass="password"
  • Encrypt the file with your pgp/gpg key:

    $ gpg -r 'gpgid' -e ~/.mutt/
    $ ls ~/.mutt/\*
    /home/user/.mutt/ /home/user/
  • Shred the plain-text file and delete it safely.

    $ shred ~/.mutt/
    $ rm ~/.mutt/

    The remaining file ~/.mutt/ is a binary and encrypted file that contains the parameters necessary for including them into the source-file. That file now needs to be imported into the mutt configuration file ~/.mutt/.muttrc

    source "gpg -d ~/.mutt/ |"

    This will decrypt and import the encrypted file into the configuration file while reading it when Mutt fires up. The pipe at the end of the command is necessary for redirecting the output back to mutt.

    When you now fire up Mutt you are gonna be asked for your pass-phrase for the PGP/GPG file - once. As long Mutt is running it will grant you access to the file and you can send and receive e-mails as usual.

    If you want to go even further search for information how to connect the gpg-agent to mutt.

Sending E-Mails as attachment

Occasionally I have to send e-mails attached to another email. This happens when I need to send some diagnostic e-mails the some vendor for instance. This is no problem at all if you know how to do it (and if you think about it)

  1. Write your e-mail as usual.
  2. Instead of lowercase 'a' you use the uppercase 'A' this time for attaching.
  3. Mutt will open your mailbox and you tag the messages you want to attach with 't'.
  4. Leave the attachment-dialog with 'x'.
  5. Send.

Forwarding attachments


When forwarding an e-mail, mutt tends to only forward the message part, but leave the attachments behind. This is actually considered to be the correct behavior, since you are forwarding usually exactly what is currently on the screen.

There are other convenient ways, to include the whole email into the forward, not only the currently displayed part.

  1. Way:

    1. type v to get to the attachments screen.
    2. Type t repeatedly to tag all the attachments, including the initial small text/plain attachment (that is the original message body).
    3. When they are all tagged, type ;f (forward all tagged attachments). After you fill in the To: prompt, you will be able to edit the message body, and when you leave the editor, you will have the attachment list there to edit as you see fit.
  2. Way: If that does not work (I have not tried it on HTML messages), there is a slightly more elaborate procedure:

    1. use Esc-e (resend-message), basically use the current message as a template for a new one. This calls up an editor on the current message, including headers.
    2. Change the From to your name, the To to your intended recipient, and edit the message body to your hearts content. When you are done, you are being sent to the Compose screen, where you can adjust the attachment list and send the message.

    Forwarding is pretty clearly not what Esc-E was intended for ... but it does the job and might be a handy trick to know.


Attachments, piping

Since we are already talking about attachments here: you can just pipe them as anything else (like the email, e.g.) to any command you like. So you can extract compress files on the file and save on step

  • Key: |
  • Command for a tar file to extract:
    Pipe to: tar -C ~/ -x


For opening URLS just install urlview:

$ sudo apt-get install urlview

Then just CRTL+b will open the URL in your browser (or all URLS available - you choose the one)


Let's just add some spellchecking to the mutt/vim editor.

Somewhere in my .muttrc or in one of the source-ed files I add the following line:

set editor="vim -c 'set spell spelllang=nb,en,de' -c 1 -c 'set textwidth=72'"

Here are three parameters set. For the spellchecking only the first one is relevant. Supported languages are set to nb, en and de. If the dictionaries for the languages are missing, VIM will ask to download them and store them under ~/.vim.

This since change only is in the .muttrc and not in the VIM configuration file, this will not apply to all the other files we might edit with VIM (like configuration files).

Unknown or misspelled files are highlighted. In case we want to add a file to the spellchecking library/file, just put the cursor over the word, go in command-mode and type zg. This will put the word into the spellchecking-file, usually placed in ~/.vim/spell/<lang>.utf-8.add (you might want to put those files under your sync solutions to keep them aligned across your systems).

If you want to actually correct the word from the suggestions the command z= gives you a selection of suggestions.


Writing mails in mutt is already faster than in outlook. Still I am missing some shortcuts certain code-files or markdown is providing. Since I find myself often also using markdown to structur my emails, setting support for markdown just was the next step.

This setting is actually done in vi/vim, since this is the editor my mutt instance uses.

So I just added the following line to my ~/.vimrc to enable markdown support:

au BufRead,BufNewFile mutt-* set filetype=markdown

Open an EML file

Mutt cannot open an eml-file directory. It's missing some information usually available in a mbox-file. Those can be created with formail

$ formail < email.eml > box.mbox


Tag all message


Move Message (all tagged)



(when email opened)


[^1] Actually, I thought about that after I have configured ELinks and will most likely use this instead.