Reading Annoying HTML Mail in Mutt

I’ve tried several solutions for reading broken HTML mail in mutt, including my own custom Python hack, addMIMETextToHTMLEmail (this was actually the first Python program I ever wrote). Reasonably nice mail clients will send a plaintext part in addition to the HTML mail for us textophilic email users, but the dominant Microsoft Hotmail and Microsoft Exchange send HTML-only mail with no plaintext part. I wonder if they do this because they expect anybody worth writing to these days is using Microsoft Outlook or Microsoft Hotmail.

I think I’ve recently discovered the best solution, since my addMIMETextToHTMLEmail script doesn’t always work properly and is probably unnecessarily complex:

  • Download and install demoroniser. You may need to tweak it slightly, since it expects perl to be in /bin/perl.
  • Install html2text (Debian package, separate source available from Martin Bayer).
  • Add to ~/.mailcap (this all needs to go on one line):
     text/html; /home/adam/bin/ -q -w0 '%s' | /usr/bin/html2text -width 90 -style pretty; copiousoutput; description=HTML Text 

    You may prefer a wider output; the person who suggested this to me uses 158.

  • Edit ~/.muttrc and add:
     set implicit_autoview=yes 
  • You should now be able to view HTML-only emails in mutt without having any extra steps.

I’m considering packaging demoroniser for Debian, although it may fall below people’s ‘this script is too small to be its own package’ threshold.

Thanks to Alec Thomas, author of xchg2mail (which I’m also planning on packaging for Debian), for the tip.


  1. Andreas Reuleaux Jan 28

    You might just want to wait: One of the improvements of the upcoming python 2.4 version is better support for parsing broken html attachments

  2. Kevin Mark Jan 28

    Hi Adam. I have these 2 entries in my /etc/mailcap. I’m curious what that advantage is to your approach.
    text/html; /usr/bin/elinks ‘%s’; needsterminal; description=HTML Text; nametemplate=%s.html
    text/html; /usr/bin/elinks -dump ‘%s’; copiousoutput; description=HTML Text; nametemplate=%s.html

  3. Steve Laniel Jan 28

    Great demoroni{s,z}ing solution, Adam; I’m using it, and it seems flawless. I’ll let you know if it ends up destroying all the data on my hard drive.

  4. Adam Rosi-Kessel Jan 28

    Kevin: your solution works as well, of course. The biggest insight here for me was set implicit_autoview=yes, which saves a step in viewing messages, which is particularly useful when every single message (in my Exchange-import email box) is HTML. The advantage of demoroniser/html2text over elinks is that you might think the output is prettier/more readable, but it’s mostly a matter of taste.

  5. Martin Bayer Jan 28

    I’m happy to know that html2text makes life easier to other people. – To make it easier to find the program, its home recently changed to a new location (used for this comment).

  6. Prayatn Feb 26

    I want mutt to display html message in seperate color. My normal color is white. I want when mutt converts html to text, it should convert it a separate color. Is it possible by this tool?

Leave a Reply

(Markdown Syntax Permitted)