Neomutt: adds better support for multipart emails

Neomutt now supports sending multipart emails better. See details in my
blog:

https://jonathanh.co.uk/blog/multipart-emails-in-neomutt/
master
Jonathan Hodgson 3 years ago
parent b18d3a0f62
commit b715061cfe
  1. 59
      bin/.bin/emails/convert-multipart
  2. 10
      mutt/.config/mutt/muttrc

@ -0,0 +1,59 @@
#!/usr/bin/env bash
# https://github.com/anufrievroman/Neomutt-File-Picker/blob/master/filepicker
# https://github.com/neomutt/neomutt/issues/3229
# https://unix.stackexchange.com/questions/612134/neomutt-run-command-to-attach-file-on-macro-key-press/612194#612194
commandsFile="/tmp/neomutt-commands"
markdownFile="/tmp/neomutt-markdown"
htmlFile="/tmp/neomutt.html"
cat - > "${markdownFile}.orig"
echo -n "push " > "$commandsFile"
cp "${markdownFile}.orig" "$markdownFile"
grep -Eo '!\[[^]]*\]\([^)]+' "$markdownFile" | cut -d '(' -f 2 |
grep -Ev '^(cid:|https?://)' | while read file; do
id="cid:$(md5sum "$file" | cut -d ' ' -f 1 )"
sed -i "s#$file#$id#g" "$markdownFile"
done
if [ "$(grep -Eo '!\[[^]]*\]\([^)]+' "$markdownFile" | cut -d '(' -f 2 | grep '^cid:' | wc -l)" -gt 0 ]; then
echo -n "<attach-file>\"$markdownFile\"<enter><toggle-disposition><toggle-unlink><first-entry><detach-file>" >> "$commandsFile"
fi
pandoc -f markdown -t html5 --standalone --template ~/.pandoc/templates/email.html "$markdownFile" > "$htmlFile"
# Attach the html file
echo -n "<attach-file>\"$htmlFile\"<enter>" >> "$commandsFile"
# Set it as inline
echo -n "<toggle-disposition>" >> "$commandsFile"
# Tell neomutt to delete it after sending
echo -n "<toggle-unlink>" >> "$commandsFile"
# Select both the html and markdown files
echo -n "<tag-entry><previous-entry><tag-entry>" >> "$commandsFile"
# Group the selected messages as alternatives
echo -n "<group-alternatives>" >> "$commandsFile"
grep -Eo '!\[[^]]*\]\([^)]+' "${markdownFile}.orig" | cut -d '(' -f 2 |
grep -Ev '^(cid:|https?://)' | while read file; do
id="$(md5sum "$file" | cut -d ' ' -f 1 )"
echo -n "<attach-file>\"$file\"<enter>" >> "$commandsFile"
echo -n "<toggle-disposition>" >> "$commandsFile"
echo -n "<edit-content-id>^u\"$id\"<enter>" >> "$commandsFile"
echo -n "<tag-entry>" >> "$commandsFile"
done
if [ "$(grep -Eo '!\[[^]]*\]\([^)]+' "$markdownFile" | cut -d '(' -f 2 | grep '^cid:' |
wc -l)" -gt 0 ]; then
echo -n "<first-entry><tag-entry><group-related>" >> "$commandsFile"
fi

@ -171,6 +171,16 @@ bind pager gg top
bind pager j next-line
bind pager k previous-line
######################
# Compose settings #
######################
macro compose Y "<first-entry>\
<pipe-entry>convert-multipart<enter>\
<enter-command>source /tmp/neomutt-commands<enter>
##############
# Contacts #
##############

Loading…
Cancel
Save