Improving mutt's handling of HTML
#376 Henry, Tuesday, 15 January 2019 12:11 PM (Category: Linux)
(Tags: mutt html)

After yesterday's success with getting mutt to show calendar invites, I looked at how I view HTMl emails. Apart from them being an abomination, and a huge security risk, sometimes I have to see them.

I used to have a .mailcap entry of:

text/html; links %s; nametemplate=%s.html

And that works okay, but I have to v to view the contents of the email, then manually select the text/html part, then m to view it with the mailcap entry. I did some reading to see if there was a way to improve this.

There was.

First I installed w3m, a small HTML to text converter. I installed it using sbopkg under Slackware.

Then I changed the .mailcap line for text/html to this:

text/html; w3m -I %{charset} -T text/html; copiousoutput

and finally, I added this line to .muttrc:

auto_view text/html

Now, when I view an email that contains a text/html section, mutt will show the HTML portion as parsed through w3m. There's rudimentary formatting, and most of the HTML will be displayed in a good-enough fashion. It works automatically, and it's better than before, so that's good.

0 comments