HTML E-mails And Mutt
June 27th, 2009
2 comments
I find myself regularly using terminals and thus have grown to love any tool that allows me to remain in terminal. Mutt is only of those, a fantastic terminal mail client. The only issue is that most people these days send HTML e-mails rather than plain text. This means that when I open them in mutt it is very unreadable. However there is a very simple solution.
First off lets make a simple script to convert the HTML into text. Several terminal based browsers exist and these can do the conversion for us (make sure to place it in your PATH somewhere).
#!/bin/sh if [ ! -z `which links | grep -v 'no links'` ] then links -html-numbered-links 1 -html-images 1 -dump "file://$@" elif [ ! -z `which lynx | grep -v 'no lynx'` ] then lynx -force_html -dump "$@" elif [ ! -z `which w3m | grep -v 'no w3m'` ] then w3m -T text/html -F -dump "$@" else cat $@ fi
Add this to your ~/.muttrc:
auto_view text/html alternative_order text/enriched text/plain text text/html
And then this to your ~/.mailcap:
text/html;html2txt %s; copiousoutput
Start up Mutt and get nothing but text e-mails.