HTML mail which isn't handled correctly by 'auto_view text/html

Cameron Simpson cs at cskk.id.au
Wed Feb 6 22:44:25 UTC 2019


On 06Feb2019 13:01, Chris Green <cl at isbd.net> wrote:
>On Wed, Feb 06, 2019 at 01:00:48PM +1100, Cameron Simpson wrote:
>> Scenario B:
>> If DHL really are sending HTML in a standalone text/plain body then 
>> you've got 2 choices.
>>
>> The first is to act when you receive the email; if you're using procmail or
>> something similar to file you email you could match these messages and
>> modify the Content-Type: header to say "text/html".
>>
>> The alternative is to match the message with mutt, and to set display_filter
>> specially for this message. You could use your normal display_filter and use
>> a message-hook to override it with the command from the mailcap ("lynx
>> -dump").
>>
>OK, thanks, it's quite rare and, at the moment, only DHL notifications
>doing this that I actually want to see the content.

Just further to the display_filter thing: I normally use a 
display_filter, set to a personal script which goes:

    #!/bin/sh
    #
    # Mutt display filter, whose behaviour adjusts accoridng to some flags.
    #   - Cameron Simpson <cs at cskk.id.au> 29jan2017
    #

    if flag MUTT_ROT13
    then  tr '[A-Z][a-z]' '[N-Z][A-M][n-z][a-m]'
    else  cat
    fi \
    | if flag MUTT_UNTOPPOST
      then  untoppost
      else  cat
      fi \
    | mutt-highlight

The mutt-highlight is a sed script which turns *foo* into bold and _foo_ 
into underlined. But the important thing here is the if statement: it 
optionally runs the message body through some filters. For example, I've 
got a mutt macro ^X to toggle the MUTT_ROT13 flag and redisplay the 
message.

You could adopt such a scheme for your HTML issue (in fact, I'm going to 
do that myself too): have an optional flag to decode the HTML using a 
pipeline flavour of your mailcap unhtml line. Then bind a mutt keystroke 
to toggle the flag and redisplay. My rot13 bindings go:

    set my_toggle_rot13="$my_push_wait_key=no<enter><shell-escape>flag !  MUTT_ROT13 -e flag MUTT_ROT13<enter>$my_pop_wait_key"
    macro index \Cx "$my_toggle_rot13" 'toggle MUTT_ROT13'
    macro pager \Cx "<exit>$my_toggle_rot13<display-message>" 'toggle MUTT_ROT13'

Just a thought. Source for any of the above is available.

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Mutt-users mailing list