Use Browsers With Mutt

I use a console-based mail user agent called Mutt to read my email. By default, it does not do anything to render HTML email. It just shows the raw HTML as plain text -- though you might need to open an HTML attachment to see it. Any remotely reasonable mail user agent or email client offers plain text as a back-up plan for cases where HTML will not render, though, so HTML-only emails are almost always spam and phishing emails, anyway.

I only really need to view an HTML email about once every six or eight months, on average. When I do, of course, I like to have some mechanism for doing so. For a while I used a script I had written myself that cleaned markup out of emails and presented it all as plain text. Alas, I managed to lose it somewhere along the way, thanks to the extreme rarity of my need for it and the fact I occasionally move to a new laptop as technology advances.

A more typical way to do things is set a configuration line in a mailcap file to direct text/html MIME types to be opened in a browser. I had tried out a browser called w3m (and distributed under the terms of the MIT/X11 License) for a while before writing my markup-cleanup script, but despite my generally keyboard-oriented way of using my computer I find w3m's interface a touch less than ideal, and got tired of it. After losing my filter script, I went back to using w3m until I got around to rewriting that program.

To use w3m to view HTML attachments, add a line like the following in either ~/.mailcap or your system-wide mailcap file (probably /etc/mailcap or something along those lines):

text/html; /path/to/w3m -T text/html '%s'; needsterminal; description=HTML Text; nametemplate=%s.html

Replace /path/to with the path to w3m on your system, of course. It should be largely self-explanatory, aside from the part that you can figure out from the w3m manpage.

I never got around to rewriting that script. Today, I decided to switch to a browser called surf instead. Like w3m, it is an MIT/X11 License application. Unlike w3m, surf is a GUI application, rather than console-based. It is also easier to use, and simple enough for purposes of viewing an HTML email once every six or eight months. The mailcap configuration I use looks something like this:

text/html; /path/to/surf 'file://%s'; nametemplate=%s.html

Enjoy.