6

For a while now I've found that when I try to view an HTML file in my browser (from Mutt, v to see all attachments, select the text/html attachment and enter) my browser opens a new tab at file:///tmp/mutt.html but consistently says

File not found

Firefox can’t find the file at /tmp/mutt.html.

Check the file name for capitalization or other typing errors. Check to see if the file was moved, renamed or deleted.

I'm not quite sure how to troubleshoot this. It worked fine until it didn't. And then just to keep me on my toes every 10th or 12th time it randomly does show the HTML mail.

For instance, just now, I ...

  • tried to view an HTML email,
  • decided I want to finally troubleshoot this,
  • started composing the first 2/3 of this question,
  • opened a second terminal tab to look at /var/log/ to see if there's an obvious log file to look at
  • ran tail -f /var/log/syslog
  • with tail follow running, went back to try viewing the HTML email again, just to see if anything is written to syslog (though I don't think it would be) and a) nothing was written to syslog, b) the same exact email actually did open just fine in a browser tab.

So ... where should I be looking for some indication of why mutt html messages sometimes open just fine in a browser and sometimes /tmp/mutt.html can't be found?

7

I had some trouble with that too. The mailcap entry for text/html is the point to look at. With chromium it was indeed the needsterminal flag. For firefox the copiousoutput flag did the trick.

#text/html; chromium %s; needsterminal
text/html; firefox %s;copiousoutput 

If you don't already have a custom mailcap, you can create a file at ~/.mailcap for example and add the firefox line to it. Don't forget to specify the path in your .muttrc

set mailcap_path  = ~/.mailcap
2
  • /etc/mailcap has multiple entries for text/html; -- is there a best practice for me to follow here? Should I be editing /etc/mailcap/ or creating my own ~/.mailcap file with custom entries? – Amanda May 23 '18 at 20:52
  • Don't edit /etc/mailcap and create your own ~/.mailcap instead. – ploth May 24 '18 at 9:01
5

Maybe it is a race condition between Firefox command line returning to mutt, and mutt deleting the temporary file before the Firefox process actually reads the file.

Try, in your mailcap entry, adding the needsterminal flag.

Or even better, instead of calling Firefox directly, call a simple shell script of yours that copies the html file with another name and then calls Firefox on that new file, before returning command to mutt (which will delete the original file).

Some people add a sleep command after calling firefox. See here or here for example (search for sleep).

1
  • text/html; /usr/bin/firefox %s & sleep 10 ; copiousoutput was the working solution for me. – Martin T. Jun 19 '20 at 8:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.