Discussion:
opening an email file/maildir in a graphical client from the command line
(too old to reply)
Javier
2020-08-23 20:39:39 UTC
Permalink
Does anybody know how to open an email file or mailbox in graphical client
(I mean X11 on linux) from the command line. HTML emails look horrible
inside mutt.
Really? I quite like how my HTML mails look with links -dump
With 'links -dump' you cannot see the hyperlink URLs in the message.
Changing your entry in ~/.mailcap to this will show them as footnotes
although the readability is slightly worser than with 'links -dump'.

text/html; lynx -force_html -display_charset=utf-8 -dump %s; copiousoutput
9 times out of 10 HTML mail is just used as a pretty useless way to
format information that could be just as easily shown in plaintext or
even something like Markdown.
Regrettably I have no choice but to deal with emails from lusers.
When I do use GUI email, I prefer Seamonkey Mail so I am quite familiar
with it.
I agree. It looks like the best choice. It's very lightweight.
I don't believe Seamonkey can handle maildir directly. You might try
something like Claws Mail, which I understand can handle maildir
natively with a plugin.
Seamonkey does support maildir.

https://www.seamonkey-project.org/releases/seamonkey2.9/changes

Support for other message storage formats (pluggable mail stores)
has been added (bug 402392).
To enable the new Maildir format (instead of the default Mbox)
for new accounts, set mail.serverDefaultStoreContractID
to "@mozilla.org/msgstore/maildirstore;1". There is no UI for
any of this yet.
(c) open a given message file.eml in a given maildir, i.e.
client --folder ${maildir} --file ${maildir}/cur/file.eml
Not sure about this, but if you point `seamonkey -mail` to the
individual message stored as a mail file within the new/cur directory,
it may work, but I have not tried.
I have just tried and works, but it is a bit picky about the filename.
The extension must be '.eml'

seamonkey -mail /path/to/file.eml

It will not work with a file within the new/cur directories in the
maildir, because it requires the .eml extension. You would need to
rename of the files to have the .eml extension in the maildir.

With Thunderbird it works as

thunderbird -file /path/to/file.eml

And it also requires the .eml extension.

I have tried with claws-mail without success.

claws-mail --select /path/to/file.eml

In general those applications are very annoying to use on the CLI.
The first time they will pester with pop-up wizards to configure a
POP/IMAP email account. The informaition given by --help option or
manpages is almost useless, and their config files format are
appalling. In the case of claws-mail they use a .ini like format,
and in the case of seamonkey/thunderbird they use a profile-dir/prefs.js
extremelly complicated format, with a lot of gotchas and not very well
documented. I am familiar with that from configuring the firefox browsers,
but is very far away from being human friendly.
Usually what I do for this is, I use `C' in mutt to save the email to a
.eml file, and then open the .eml file in Seamonkey.
Do it inside mutt with a script and a macro to .

cat >> /usr/bin/eml_view <<EOF
#!/bin/sh
eml_file=$(mktemp).eml
cat > ${eml_file}
( seamonkey -mail ${eml_file}; ) &
# run in a subshell to avoid mutt waiting for command completition
EOF

chmod a+x /usr/bin/eml_view

cat >> .muttrc <<EOF

macro attach , "<pipe-message>/usr/bin/eml_view<enter><refresh>"
macro pager , "<pipe-message>/usr/bin/eml_view<enter><refresh>"
macro index , "<pipe-message>/usr/bin/eml_view<enter><refresh>"
EOF
Eike Rathke
2020-08-23 21:27:17 UTC
Permalink
["Followup-To:" header set to comp.mail.mutt.]
Post by Javier
Does anybody know how to open an email file or mailbox in graphical client
(I mean X11 on linux) from the command line. HTML emails look horrible
inside mutt.
Really? I quite like how my HTML mails look with links -dump
With 'links -dump' you cannot see the hyperlink URLs in the message.
You can if you use elinks, they are numbered [1] like this [2] and listed
as footnotes at the end of the output like

[1] https://example.com/1
[2] https://example.com/2

Recommendable ~/.mailcap entry (one line)

text/html; /usr/bin/elinks -localhost 1 -no-connect 1 -force-html -dump %s; copiousoutput; description=HTML Text; nametemplate=%s.html

If the output in some cases is not satisfactory it can be viewed in
Firefox by piping the text/html attachment (hit 'v' on the message to
display attachments and then '|' pipe key on the attachment and enter
the script name) to a script

#!/bin/bash
TMPFILE="/tmp/$(basename $0)_$$.html"
cat>$TMPFILE
firefox $TMPFILE &
sleep 11
rm $TMPFILE

The sleep is necessary to allow Firefox to start and read the temporary
file before removing it.

Instead of hardcoding firefox (or any other browser) it's also possible
to use xdg-open for the user's preferred application.

Eike
--
OpenPGP/GnuPG encrypted mail preferred in all private communication.
GPG key 0x6A6CD5B765632D3A - 2265 D7F3 A7B0 95CC 3918 630B 6A6C D5B7 6563 2D3A
Use LibreOffice! https://www.libreoffice.org/
Loading...