57 lines
2.7 KiB
Markdown
57 lines
2.7 KiB
Markdown
Here's what I do. I'm using neomutt. I don't recall whether that's important for this procedure or not.
|
|
|
|
In my muttrc I have this line:
|
|
|
|
macro compose K "<pipe-message>$HOME/.mutt/make-alternative.sh<enter><attach-file>/tmp/neomutt-alternative.html<enter><tag-entry><previous-entry><tag-entry><group-alternatives>"
|
|
|
|
That make-alternative.sh file is this:
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
# Juice is https://www.npmjs.com/package/juice
|
|
# So expects to be installed via `sudo npm i -g juice`
|
|
|
|
juice <(pandoc --standalone --template=$HOME/.mutt/template.html --from=commonmark --to=html) /tmp/neomutt-alternative.html
|
|
|
|
As you can see from the command, it relies on pandoc and juice. pandoc is used to convert from markdown (I like Commonmark so I've told it to use that dialect) to HTML.
|
|
|
|
The juice binary is installed as mentioned in the comment. It inlines CSS to the HTML tags. That CSS is in the template.html file which is also referenced, and contains this:
|
|
|
|
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta name="viewport" content="width=device-width">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
<title>-</title>
|
|
<style>
|
|
img {
|
|
max-width: 100%;
|
|
}
|
|
blockquote {
|
|
/* These styles are copied from what Gmail sends */
|
|
margin: 0px 0px 0px 0.8ex;
|
|
border-left: 1px solid rgb(204,204,204);
|
|
padding-left: 1ex;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
$body$
|
|
</body>
|
|
</html>
|
|
|
|
As commented there, the blockquote style is pulled from what Gmail sends in its emails. I presume I added that (this is years ago) because the default stood out like a sore thumb, or something.
|
|
|
|
For usage, in the compose window (that's after you save and close the message editor, where you can see all the from and to and subject and attachments), I make sure the text/plain attachment is highlighted and I press K. That runs the macro. It runs the plain text through pandoc, adds the HTML version, then selects both and makes them a multipart/alternative group.
|
|
|
|
What I like:
|
|
|
|
When I've made a long complicated email with headings and lists and stuff I can use this macro before sending, and I know it'll be readable and won't get screwed up when forwarded or in quoted replies etc. Especially important if it's a list of questions and I'm expecting someone to reply to each inline.
|
|
|
|
It doesn't care about what I use to actually send the mail, so no sendmail/SMTP reconfiguration is necessary.
|
|
|
|
What I don't like:
|
|
|
|
Once I've run the macro, as far as I can tell (neo)mutt provides no way to ungroup the alternatives, or for me to edit/split them. So there's no way to undo, as far as I know. That means I have to know I'm finished and won't need to edit again before I run it.
|
|
|