Strip HTML in mutt

A quick fix for conveniently reading (and replying to) HTML MIME emails in mutt mail agent.

Here’s the 3-step solution:

  1. Add the following line to ~/.muttrc
    auto_view text/html
  2. Add another line, to ~/.mailcap
    text/html; lynx -dump %s; copiousoutput; nametemplate=%s.html
  3. (Optional, but Strongly recommended) Add the following line to ~/.bashrc
    export TMPDIR=$HOME/tmp
    (and do a mkdir ~/tmp of course)

If you don’t do the 3rd step you’re getting yourself under all sorts of risks associated with using common /tmp directory – that’s what mutt will use by default for all HTML emails you view, The temp files stored in /tmp will be stored unencrypted, while your HOME‘s tmp may be protected with the homedir’s ecryptfs.

And while you’re at it you can add more mailcap entries like this:

auto_view text/html text/enriched application/x-gunzip application/postscript image/gif application/x-tar-gz

– with the corresponding lines going to ~/.mailcap (see Mutt MIME docs for details)