From time to time I receive e-mails that have a multipart/alternative MIME type and offer the e-mail body in a text/plain version as well as a text/html version. Unfortunately, the text/plain version is sometimes broken, containing either a plain copy of the text/html body, having no content at all or providing even useful hints such as:
This e-mail may only be displayed in HTML.
All of those sites happily ignore the meaning of the multipart/alternative MIME type as specified in RFC 2046:
… In particular, each of the body parts is an “alternative” version of the same information.
Systems should recognize that the content of the various parts are interchangeable. Systems should choose the “best” type based on the local environment and references, in some cases even through user interaction. …
In mutt, one can quickly display other MIME types by pressing the v
key when viewing a message and selecting another MIME entry. Most of the
time this is sufficient, but for certain sites where I know in advance
that their text/plain version of the e-mail is broken, I want to
automatically view the text/html version of the e-mail.
One way to achieve this, is by using a message-hook together with the alternative_order muttrc setting. The following alternative_order prefers the text/plain version over the text/html version:
alternative_order text/plain text/html
To automatically select the text/html version for certain e-mails, I use the following message-hooks in my muttrc:
# The default alternative_order: prefer text/plain over text/html.
message-hook '.' 'unalternative_order *; alternative_order text/plain text/html'
# These sites send a multipart/alternative header while having a broken
# text/plain MIME part. Select text/html as preferred MIME part.
message-hook '~f agent@willhaben\.at$' 'unalternative_order *; alternative_order text/html'
message-hook '~f post\.at$' 'unalternative_order *; alternative_order text/html'
The default message-hook (with the . in the pattern field) resets the alternative_order and sets it to prefer text/plain over text/html. Each of the following lines overrides the default alternative_order and prefers the text/html version for sites that send broken text/plain versions.
Have fun.