HTML email?

Cameron Simpson cs at cskk.id.au
Thu Apr 8 21:48:15 UTC 2021


On 07Apr2021 07:22, John Niendorf <jfn at startmail.com> wrote:
>How do you all deal with HTML email?

Composing HTML is a can of worms. I'd need to dig into the list archives 
- it has been discussed.

Displaying HTML uses 2 main settings:

The .mailcap entry for text/html with the "copiousoutput" flag. For 
example:

    text/html; exec 2>&1 && env DISPLAY= unhtml %s; copiousoutput

"unhtml" is a personal script which invokes whatever I prefer to use to 
transcribe HTML as plain text. Currently it invokes:

    lynx -stdin -dump

That way I don't have to hack my mailcap much, better to hack the script 
if I shift tools, eg to w3m.

The other setting is the alternative_order setting, which says which 
Content-Type to prefer of a multipart/alternative message. These usually 
have a text/plain and text/html part (though of course they course have 
other things, eg a text/markdown part). My default setting is:

    alternative_order text/plain text/html

which prefers the plain text version, sidestepping the HTML altogether.

However, there are plenty of platforms which are HTML first and provide 
either very poor plaintext equivalents of empty ones, or ever just stuff 
the raw HTML into both parts. Absolutely rubbish quality of 
implementation, but there you go.

So in fact I choose the alternative order per message:

    # alternative-order criteria
    message-hook . 'unalternative_order *; alternative_order text/plain text/html'

    message-hook '~h "X-Mailer: Apple Mail" ~X 1-' 'unalternative_order *; alternative_order text/html multipart/mixed text/plain'

    message-hook '%f htmlers | ~f @no-reply at cc.yahoo-inc.com | ~f @outlook.com | ~f live.com | ~f @facebookmail.com' 'unalternative_order *; alternative_order text/html text/plain'

So far all messages I set up the default. Then for Apple Mail I put the 
HTML first because of the way Apple Mail packs attachments, which is 
weird. Then for an elite set of negligent idiots I put HTML first 
because I _know_ that they shift a plaintext version and the plaintext 
is always rubbish.

That last criterion is email from outlook.com, live.com, facebook.com, 
yahoo's PR/info people, and whomever I have explicitly added to my mutt 
"htmlers" group.

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


More information about the Mutt-users mailing list