I'm using mutt to process my mail. There is one sender which declares the wrong content type. The mail arrives with

Content-Type: multipart/alternative;

and has two parts. They are declared as:

Content-Type: text/plain; charset=utf-8


Content-Type: text/html; charset=utf-8

However both parts of the mail are same. So the plaintext part is full of HTML tags as well as the HTML part. I've tried to discuss it with the sender, but they use some kind of 'enterprise' software where they cannot change those settings.

So I'd like to change the mail locally and maybe remove the text/plain-part or rewrite text/plain to text/html.

What do you consider the best way and what tools can I use to get a readable mail in my case?

1 Answer 1


In mutt, you can type v, and then select the alternative you want to display. You can also change the content-type of a part with Ctrl-E.

As a more generic approach, you could use mutt's display_filter setting:

set display_filter=/path/to/mutt-filter

With mutt-filter being something like:

#! /usr/bin/awk -f
  cmd="echo '[automatically converted from html to text]'; w3m -T text/html -dump"
l ~ /<html|<!doctype html/,l ~ /<\/html>/ {
  print | cmd
{close(cmd); print}

Which would cause (in what mutt is going to display, not the raw email) anything between <html> and </html> to go through w3m -T text/html -dump (or elinks -dump or your preferred html to text converter).

As that might convert things that it's not meant to (like when <html> does appear in a genuine text/plain part), you might want to adapt it so that it only operates on emails from those guys that send bogus emails, or some even fancier approach like counting the number of tags and convert when reaching a threshold...

  • Thanks. I'm aware of these possibilities. I'm looking more for an automated approach. <kbd>v</kbd> and HTML is set to open an external browser (and I'd like it to keep that way). <kbd>Ctrl-E</kbd> does only edit the content type of the whole mail not individual parts.
    – qbi
    Jan 29, 2013 at 15:24
  • 1
    @qbi, if you type CTRL-E on the currently selected part, it edits that part's content-type. Jan 29, 2013 at 15:26
  • @qbi, I've updated the answer with another possible approach. Jan 29, 2013 at 20:26
  • @qbi, with w3m, you need to add -T text/html Jan 30, 2013 at 7:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.