:: Re: [DNG] mutt and html
Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Bob Proulx
Fecha:  
A: dng
Asunto: Re: [DNG] mutt and html
Hendrik Boom wrote:
> Until upgraded from ascii to beowulf, HTML messages were tolerable.
> Either they were obvious crap, in which case I just deeted them,
> or they seemed like they were worth viewing, in which case they were
> usually html attachments, and I could seen the list of attachments by
> typeing v and selecting the html version -- in which case it would
> open for me in the chromium browser.
>
> This stopped working after the upgrade to beowulf.


Until I read that you are connecting with ssh -X I thought that this
is almost certainly due to changes in /etc/mailcap handlers. You
might review them on your system anyway. It is possible they have
changed for you with the upgrade and that is why your html handling
has changed.

    [[ Time to advocate for "etckeeper".  If that is installed then one can
    look at the changes over time to any particular file in /etc.  This is
    the command line way to view the "patches" made to a file.


        cd /etc
        git log -p mailcap | less


    Meanwhile...  I normally just emacs the file, browse the version
    history inside the Emacs git blame interface, C-x v g, and navigate
    through previous and next versions.  I am sure there are many other
    git version history browsers available. ]]


Here is a sampling of html handlers from my system, which will not be
typical since every system will have different ordering based upon the
ordering in which packages were installed and removed. Packages add
and remove handlers as they are modified. But useful for the idea.

    $ grep html /etc/mailcap
    text/html; /usr/bin/sensible-browser %s; description=HTML Text; nametemplate=%s.html
    text/html; /usr/bin/firefox %s; description=HTML Text; test=test -n "$DISPLAY";  nametemplate=%s.html
    text/html; /usr/bin/firefox-esr %s; description=HTML Text; test=test -n "$DISPLAY";  nametemplate=%s.html
    text/html; /usr/local/bin/chromium %s; test=test -n "$DISPLAY"
    application/xhtml_xml; /usr/local/bin/chromium %s; test=test -n "$DISPLAY"
    text/html; /usr/bin/chromium %s; test=test -n "$DISPLAY"
    application/xhtml_xml; /usr/bin/chromium %s; test=test -n "$DISPLAY"
    text/html; dwb %s; test=test -n "$DISPLAY"
    application/xhtml+xml; dwb %s; test=test -n "$DISPLAY"
    text/html; midori --private %s; test=test -n "$DISPLAY"
    application/xhtml+xml; midori --private %s; test=test -n "$DISPLAY"
    text/html; /usr/bin/elinks -force-html %s; needsterminal; description=HTML Text; nametemplate=%s.html
    text/html; /usr/bin/links %s; needsterminal; description=HTML Text; nametemplate=%s.html
    text/html; /usr/bin/w3m -T text/html %s; needsterminal; description=HTML Text; nametemplate=%s.html
    text/html; /usr/bin/elinks -force-html -dump %s; copiousoutput; description=HTML Text; nametemplate=%s.html
    text/html; /usr/bin/links -dump %s; copiousoutput; description=HTML Text; nametemplate=%s.html
    text/html; /usr/bin/lynx -force_html %s; needsterminal; description=HTML Text; nametemplate=%s.html
    text/html; /usr/bin/w3m -I %{charset} -dump -T text/html %s; copiousoutput; description=HTML Text; nametemplate=%s.html
    text/html; /usr/bin/html2text %s; copiousoutput; description=HTML Text
    text/html; /usr/bin/lynx -dump -force_html %s; copiousoutput; description=HTML Text; nametemplate=%s.html


I keep a personalized ~/.mailcap file with most of the selections I
care about. I then uncomment the one I want to be using at the
moment if I want to do something different and want to force my choice.

    # text/html; /usr/bin/firefox %s; description=HTML Text; test=test -n "$DISPLAY";  nametemplate=%s.html
    # text/html; /usr/bin/elinks -dump -dump-color-mode 3 %s; copiousoutput; description=HTML Text; nametemplate=%s.html
    # text/html; /usr/bin/elinks -dump %s; copiousoutput; description=HTML Text; nametemplate=%s.html
    text/html; /usr/bin/links -dump %s; copiousoutput; description=HTML Text; nametemplate=%s.html
    # text/html; /usr/local/bin/iceweasel '%s'; description=HTML Text; test=test -n "$DISPLAY";  nametemplate=%s.html
    # text/html; /usr/bin/lynx -force_html %s; needsterminal; description=HTML Text; nametemplate=%s.html
    # text/html; /usr/bin/lynx -dump -force_html %s; copiousoutput; description=HTML Text; nametemplate=%s.html
    # text/html; /usr/bin/w3m -no-mouse -T text/html %s; needsterminal; description=HTML Text; nametemplate=%s.html


Currently I am forcing "links -dump" rendering as that is doing pretty
well for the types of html mail I am receiving at the moment. For
most html mail I am receiving the text rendering of the message is
more than sufficient. There are hard cases of fluff and glitter
though. If I have a problem I will simply edit that ~/.mailcap file
and change the selection and try one of the others viewers. Some work
better than others.

If I want to open the attachment in a real graphical browser then I
perform a manual action. I 'v'iew the MIME parts, select the html
part, save that html part to a temporary file location such as
/tmp/mutt.html but any temporary location you prefer is okay,
selecting (o)verwrite in mutt as needed if I have a previous file
there. Then open that in Firefox manually. Usually with Control-l in
Firefox to select the Location Bar, then typing in /tmp/mutt.html
Enter. Or on the command line with "firefox /tmp/mutt.html". Then I
see the rendered html in the web browser and interact with HTML links
from there.

Yes this is manual but it is not difficult and I only need to do this
on particularly difficult html emails. Ones that expect or require
interaction to do anything. Surveys mostly. Or if a business I need
to interact with is requiring my input. Sometimes for 2FA (two
factor) authentication when a web site is using email for
authentication.

Maybe this isn't your main problem since you are using ssh -X and it
seems things are working but going to the wrong display. But perhaps
the above will be interesting to others. And since I am advocating I
will mention PDF handling. Which is related for mutt handling.

For PDF attachments I find that "pdftotext -layout" does a very good
job with most constructed PDFs. Things like automatically generated
invoices and bills and bank statements. All of my bank statements are
very readable using it. However it does not display PDF scanned
images which are really just images encapsulated into a PDF. Of
course those need to be viewed as their raw images. But since for me
all of my bank statements and invoices sent by email work very well
with "pdftotext -layout" I mostly don't need anything more than this
following ~/.mailcap entry.

    application/pdf; /usr/bin/pdftotext -layout %s -; copiousoutput; test=test "$DISPLAY" = ""; description=Portable Document Format; nametemplate=%s.pdf


Note that the mailcap entries all use a test of "$DISPLAY" to select
whether to run the text mode conversions or not. If there is a
graphical display as denoted by $DISPLAY being set then it falls
through and selects a later defined graphical handler. If one wants
to force a text mode handler regardless then adjust or remove that
test of $DISPLAY as desired.

> I did manage to reconfigure, telling it to use firefox-esr, but that
> didn't help much.
>
> I connect to my server, the machine on which I run
> mutt, using ssh -X.
> So firefox on the server detects I already have a firefox browser
> on my laptop and proceeds to give the job of browsing the message to
> my laptop.
> Makes sense, except that my laptop has no way to access the
> /tmp/mutt/somethingorother.html on the server.


Doing it fully manually you could save the html attachment to a
temporary file on your server at /tmp/mutt.html for example, then copy
that file from there back to your laptop "by your favorite method"
such as with rsync, then open chromium on it locally with Control-l to
get to the Location Bar and then /tmp/mutt.html Enter to open it, or
by running "chromium /tmp/mutt.html" on the command line. Some
scripting might help. Unfortunately the direction of copy and the
place where it is triggered is on your server not your laptop. The
other way would be trivial by this is the other direction. I think of
a number of kludges but nothing I want to suggest. But it would work
when done manually.

> And I have not been able to get mutt to call chromium at all.


Where is chromium installed for you? Does it match an entry in the
/etc/mailcap file? Something like this? Or is it located in a
different path?

Look at the MIME type of the attachment trying to be viewed. Is it
something other than text/html? Perhaps something unexpected like
application/xhtml or something? One that is not matching any of the
existing mailcap entries?

    text/html; /usr/bin/chromium %s; test=test -n "$DISPLAY"


Try adjusting as needed into a custom entry and putting that into your
personal ~/.mailcap file. Then it should definitely work.

Bob