Running mutt remotely on the same server as your email is fantastic as there is no need for POP or IMAP, you can just read the Postfix MailDir directly. The only downside is viewing image attachments; Word documents and PDFs are mostly fine using appropriate command line converters.

I’ve searched and found a few approaches to solving this problem, such as scripts to host the images temporarily on a web server, but I liked the sound of this approach best which uses a single keyboard shortcut to copy the image to a local machine and open it.

For security reasons though (nothing to do with my inability to get the reverse tunnelling working, oh no) I decided to settle for a two step process:

  1. A keyboard shortcut to use in Mutt in the remote session to save the image attachment to a fixed location and filename on the server (I have the following in in my .muttrc):

    macro attach I "<save-entry><kill-line>~/Downloads/mutt/muttimage<enter>"

  2. And a command to run locally that copies the image from the server, displays it, and after the viewer has quit deletes both the local and remote copies of the image (I have this alias in my .mkshrc):

    alias sxivmutt="scp my.lovely.server:/home/me/Downloads/mutt/muttimage ~/muttimage; sxiv muttimage; rm muttimage;ssh my.lovely.server rm /home/me/Downloads/mutt/muttimage"

Since I use ControlMaster the scp and ssh commands don’t require me to enter any passwords.

All quite simple really, but much more streamlined than saving the attachment under its actual filename and using sftp to get it and then trying to remember which file it was you just saved - enough that I don’t put off viewing attachments any more.