:: Re: [DNG] Question .mailcap entry f…
Top Page
Delete this message
Reply to this message
Author: Antoine
Date:  
To: dng
Subject: Re: [DNG] Question .mailcap entry for text/html mutt reading HTML emails
On Friday, 21 November at 00:25, Walter Dnes wrote:
> I'm running mutt in X. The default is raw HTML spewage. Setting...
>
>text/html; w3m -I %{charset} -T text/html; copiousoutput;
>
>...gives me readable text. I'd prefer to launch a browser but both...
>
>text/html; /usr/bin/chromium --profile-directory="Default" %s;
>text/html; /usr/bin/chromium --profile-directory="Default" %s; nametemplate=%s.html;
>
>...fail. What am I missing?


I fiddled around for a while with text/html in my mailcap file and
eventually decided to feed the HTML part through a shell script.

mailcap file
------------

text/html; $HOME/html_attachment.sh

html_attachment.sh
------------------

TEMPDIR="/tmp/mail_HTML_${RANDOM}"
mkdir $TEMPDIR
sed -r -z '
s/=3D/=/g;
s/=\n//g;
s/=([0-9A-F]{2})(=([0-9A-F]{2}))?(=([0-9A-F]{2}))?/\&#x\1\3\5;/g;
s/<\//<\//g' -> ${TEMPDIR}/attached_file.html
$BROWSER ${TEMPDIR}/attached_file.html&

The sed line is a bit complicated, obviously, but it just converts
e-mail extended character encoding to HTML extended character encoding
and tidies the source up a bit so browsers can read it more cleanly.
I've probably missed some cases.

I believe this would work with and without a GUI.

It only displays the HTML part. If there are any other parts (CSS,
javascript, pictures...) this script ignores them. I think this is a
limitation with mutt, but it works well enough for me. If I really need
to see pictures, I press "v" in mutt, choose the image part and open
that (image/* defined in the mailcap file).

Best of luck,
- Antoine

--
Explosives. If they don't solve the problem,
they at least make it entertaining.