You are not logged in.
I usually read my email by ssh'ing to the NetBSD system that hosts my mail, and using Mutt there. Sometimes I do need to more easily see HTML email, images, etc. from my (Arch) desktop, so I set up Mutt there to connect via IMAP to my mail system. But I can't seem to get my mailcap to work correctly.
There's an /etc/mailcap on my system, which identifies itself as a Red Hat mailcap file. It pretty much just calls xdg-open for a half-dozen MIME types. So, for example, it includes:
image/*; /usr/bin/xdg-open %s
text/html; /usr/bin/xdg-open %s ; copiousoutput
If I open Mutt on my desktop and navigate to the text/html part of an email, it will open it in Brave, even though I have Vivaldi set as my default browser. (It also opens it as raw text; i.e. it doesn't render the CSS or HTML.) So in my personal ~/.mailcap file, I added:
text/html; /usr/bin/vivaldi %s
This has no effect; it still opens with Brave.
Similarly, if I run xdg-open on the commandline with a .jpg target, it opens up in Brave. But if I add to my own .mailcap file
image/*; /usr/bin/ristretto %s
(ristretto being my image viewer of choice), and in Mutt I navigate to a .jpg attachment, it _does_ open up in ristretto, suggesting that my .mailcap is being read and listened to in this case
How do I figure out why Mutt isn't using Vivaldi to display my text/html attachments? And in particular, getting it to render the output would be preferable!
(Edit: added code tags)
Last edited by the_jest (2024-02-16 18:22:44)
Offline
That looks like an XDG association problem. Check the following:
xdg-settings get default-web-browser
My guess is it will show Brave as the default. To change it to Vivaldi:
xdg-settings set default-web-browser vivaldi-stable.desktop
But honestly, in Mutt I just pipe HTML emails through w3m like so (in ~/.mailcap):
text/html; w3m -dump -o display_link_number=1 -I %{charset} -T text/html; copiousoutput
That way I can read the HTML email within Mutt directly, no need to open in an external browser.
Offline
That looks like an XDG association problem.
Yes, that's part of it, but that's not really the thing I'm asking about here. That question is, why does adding
text/html; /usr/bin/vivaldi %s
to my .mailcap not clobber the XDG line in /etc/mailcap, and force Mutt to open Vivaldi?
But honestly, in Mutt I just pipe HTML emails through w3m like so
Fair, and in fact in the .mailcap on the NetBSD system where I mentioned that I do read my mail normally, I have the line
text/html; w3m -I %{charset} -T text/html; copiousoutput;
But there are times when the email is so heavily designed in HTML, with multiple images, links, forms, etc. that I do want to interact with it in an external browser, and I'm asking how to accomplish this.
Offline
It also opens it as raw text; i.e. it doesn't render the CSS or HTML
Are you sure it's actually the html part you're opening (ie. it is designated as text/html and not just html in some text/plain)?
You probably also want
text/html; /usr/bin/vivaldi %s ; copiousoutput
Offline
Hmm, interesting.
Yes, when xdg-open opens Brave, it's a text/html attachment, but Brave opens it up as unrendered HTML.
And you're right; adding ; copiousoutput was necessary, but it leads to another problem: it launches Vivaldi, but Vivaldi gives the error "Your file couldn’t be accessed/It may have been moved, edited, or deleted." I have no idea how to debug this with Vivaldi.
So it seems that right now, I have two different possibilities, neither of which works:
text/html; /usr/bin/xdg-open %s ; copiousoutput
opens Brave, with the unrendered HTML of the attachment, and
text/html; /usr/bin/vivaldi %s ; copiousoutput
but Vivaldi can't find the /tmp file.
Offline
vivaldi will likely fork, return and the tmpfile gets deleted before vivaldi actually tries to access it.
You could wrap it in some script that runs
#!/bin/sh
/usr/bin/vivaldi "$1"
sleep 30 # to give vivaldi some time
and use that in mailcap
Offline
Getting closer! That succeeds in getting Vivaldi to open the file. However, like Brave, Vivaldi simply displays the raw text of the HTML document.
Out of curiosity, I tried this with Firefox, the only other graphical browser I have on my Arch system. This also required me to create a wrapper script, but in this case, Firefox did render everything correctly.
I assume this is outside of the remit of my original question, but if you had any ideas of why two browsers are refusing to render this, or what kind of questions I could ask on their respective forums to help answer this, I'd be most grateful.
Offline
#!/bin/sh
echo '<!DOCTYPE html><html><head><title>MAIL</title></head><body>' > "${1}.htm"
cat "$1" >> "${1}.htm"
echo '</body>' >> "${1}.htm"
/usr/bin/vivaldi "${1}.htm"
sleep 30 # to give vivaldi some time
rm "${1}.htm" # cleanup
Offline
I don't know why this works; several of the existing messages I was trying to open did already begin with an HTML declaration and end with a closing </body> tag. But after thinking about it for a while, I realize I am happy enough that it does work, and grateful to you for all the help.
Offline
The browser will likely just not care about the nested html, you could test the result of "grep '<html>' $1" to control the rewrite.
Offline
#!/bin/sh echo '<!DOCTYPE html><html><head><title>MAIL</title></head><body>' > "${1}.htm" cat "$1" >> "${1}.htm" echo '</body>' >> "${1}.htm" /usr/bin/vivaldi "${1}.htm" sleep 30 # to give vivaldi some time rm "${1}.htm" # cleanup
Thank you very much! There was no way I could implement this! Now mutt opens HTML in the browser!
Thank you thank you thank you! )
Offline