Skip to content

Instantly share code, notes, and snippets.

@Konfekt
Last active May 9, 2023 19:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Konfekt/acce52d3b0283f0c357125ddee2bb2e8 to your computer and use it in GitHub Desktop.
Save Konfekt/acce52d3b0283f0c357125ddee2bb2e8 to your computer and use it in GitHub Desktop.
View mail from Mutt in GUI Browser or E-Mail client under Windows, be it via WSL or Git Bash

To be able to view an E-Mail from Mutt under Windows either using the Windows Subsystem for Linux (WSL) or MSYS2 (as delivered with Git Bash)

  • in your default GUI E-Mail client by selecting the e-mail and hitting E(mail),
  • in your default GUI browser by selecting the attached HTML file and hitting B(rowser),

do as follows:

For WSL

Add to ~/.muttrc the lines

macro pager  E        "<pipe-message>iconv -c --to-code=UTF8 > ~/.cache/mutt/mail.eml<enter><shell-escape>~/bin/wsl-open.sh $HOME/.cache/mutt/mail.eml<enter>"
macro attach B        "<pipe-entry>iconv -c --to-code=UTF8 > ~/.cache/mutt/mail.html<enter><shell-escape>~/bin/wsl-open.sh $HOME/.cache/mutt/mail.html<enter>"

and save under the path ~/bin/wsl-open.sh this shell script

#!/bin/sh
eval cmd.exe /c /start /b "$(wslpath -w "$1")"

or, better, wsl-open.sh.

For MSYS2

Add to ~/.muttrc the lines

macro pager  E        "<pipe-message>iconv -c --to-code=UTF-8 > $XDG_CACHE_HOME/mutt/mail.eml<enter><shell-escape>`echo ""\""${EMAIL:-start}""\""` $XDG_CACHE_HOME/mutt/mail.eml 2>/dev/null<enter>"
macro attach B        "<pipe-entry>iconv -c --to-code=UTF-8 > $XDG_CACHE_HOME/mutt/mail.html<enter><shell-escape>`echo ""\""${BROWSER:-start}""\""` $XDG_CACHE_HOME/mutt/mail.html 2>/dev/null<enter>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment