Reading HTML email with Mutt

Posted by Steve on Mon 10 Jan 2005 at 15:13

Tags: ,

Mutt is a console based mail client which can connect to IMAP, or POP3 mail servers. It can also read and write to local mailboxes. For a console client it's very sophisticated, allowing you to customize your setup enormously. One thing that it lacks by default is the ability to read HTML emails though.

If you wish to view HTML mails inside the mutt user interface you'll need to make two changes.

First of all you setup a mailcap file which will automatically dump the HTML text to a readable text-only display, via lynx, links, or w3m. Then you need to tell Mutt that it should do this automatically for all HTML files.

Save the following in a file called ".mailcap" in your home directory. If you already have such a file just add it to the end:

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

If you prefer a different program to render your HTML you can change the links command to that instead - for example w3m, or lynx.

Now we tell mutt that it should automatcally view the text/html parts of message by adding the following to the .muttrc file in our home directory:

auto_view text/html

These two changes should be enough to make sure that Mutt will dispaly HTML mails for us, and allow us to reply to them properly.

Many more things in mutt can be customized, and if you're using it for any length of time you're definately encouraged to read the mutt manual available on the Mutt homepage.

Share/Save/Bookmark


Posted by Anonymous (82.182.xx.xx) on Tue 11 Jan 2005 at 08:34
/dev/null

[ Parent | Reply to this comment ]

Posted by davee (80.68.xx.xx) on Tue 11 Jan 2005 at 10:28
[ Send Message ]

/dev/null

Damn, you beat me to it ...

[ Parent | Reply to this comment ]

Posted by Anonymous (68.163.xx.xx) on Sun 16 Jan 2005 at 22:30
And I reply back with /dev/zero .... :)

[ Parent | Reply to this comment ]

Posted by Anonymous (217.230.xx.xx) on Thu 3 Feb 2005 at 16:16
http://w3m.sourceforge.net/

W3M is by far the best ncurses-browser.

Try it.

Another thing: why did you not include a tip for opening the HTML-mail in a new tab in Firefox via "firefox -remote"?

[ Parent | Reply to this comment ]

Posted by Steve (82.41.xx.xx) on Thu 3 Feb 2005 at 16:18
[ Send Message | View Steve's Scratchpad | View Weblogs ]

Because I only read email with mutt, that's why!

I've used IMAP, POP3, and various clients over the years, but nothing has the power and customization of Mutt, except possibly emacs..

Steve
-- Steve.org.uk

[ Parent | Reply to this comment ]

Posted by dannyboy (128.253.xx.xx) on Mon 14 Feb 2005 at 18:29
[ Send Message ]
I use html2text, and this mailcap entry:

text/html; /usr/bin/html2text -nobs %s; copiousoutput; description=HTML Text

-nobs (no backspace) tells it to exclude special characters for bold and similar that are interpreted by less.

(I wonder if this is like slashdot, and posting to an old article is like talking out loud in an empty room.)

[ Parent | Reply to this comment ]

Posted by Steve (82.41.xx.xx) on Mon 14 Feb 2005 at 19:08
[ Send Message | View Steve's Scratchpad | View Weblogs ]

At least I've seen the comment - as will anybody else that arrives here via google :)

Steve
-- Steve.org.uk

[ Parent | Reply to this comment ]

Posted by dannyboy (128.253.xx.xx) on Wed 16 Feb 2005 at 17:05
[ Send Message ]
After some experimentation, I found that links is far superior to html2text. links runs faster, and produces better formatted output. html2text will actually seem to lock up on complicated and ugly HTML mail (I suspect it's just being slow). links handles those same messages elegantly.

Thanks, Steve! My ~/.mailcap has been updated.

[ Parent | Reply to this comment ]

Posted by Anonymous (213.112.xx.xx) on Sat 24 Dec 2005 at 11:37
I'm reading your comment now, so no sir :D

[ Parent | Reply to this comment ]

Posted by Anonymous (2001:0xx:0xx:0xxx:0xxx:0xxx:xx) on Wed 7 Jan 2009 at 16:53
Definately not - three years on your echoes ring true. Thanks for the tip on html2text, makes email usable again :)

[ Parent | Reply to this comment ]

Posted by Anonymous (82.38.xx.xx) on Sat 10 Dec 2005 at 11:02
Just the job! So much simpler and less convoluted that other advice Google provided. This works just fine for mutt on Ubuntu 5.10.

[ Parent | Reply to this comment ]

Posted by Anonymous (62.163.xx.xx) on Fri 6 Apr 2007 at 01:19
Adding something to ~/.mailcap doesn't work for me.
I need to create/add it to ~/.mutt/mailcap

Also, I have ~/.mutt/muttrc instead of ~/.muttrc

Using debian 'testing', April 2007.

[ Parent | Reply to this comment ]

Posted by Anonymous (81.5.xx.xx) on Wed 27 Feb 2008 at 10:34
I also add this so that it picks text/plain if it has a choice:

alternative_order text/plain

[ Parent | Reply to this comment ]

Posted by Anonymous (129.128.xx.xx) on Fri 16 May 2008 at 19:18
Great .. works as advertised ;)

BTW, do you know how to get links to decode characters properly? I'd like to read html email with mutt encapsulating Chinese characters. Thanks.

[ Parent | Reply to this comment ]

Posted by Anonymous (203.200.xx.xx) on Fri 26 Sep 2008 at 05:51
Works smooth!!

[ Parent | Reply to this comment ]

Posted by Anonymous (144.32.xx.xx) on Wed 22 Jul 2009 at 17:24
If you add "-html-numbered-links 1" to the links command then you also get a nice list of links at the bottom of the page.

[ Parent | Reply to this comment ]

User Login

Username:

Password:

[ Advanced Login ]

Register Account

Quick Site Search