Work on mutt scripts

Jonathan Hodgson 5 years ago
parent d48a1ffc84
commit b5a04808a0
  1. 0
      bin/.bin/emails/convertToHtmlMultipart
  2. 27
      bin/.bin/emails/send-from-mutt

@ -1,4 +1,27 @@
#!/bin/sh #!/bin/sh
EMAIL=$(pass Email/protonmail | grep BridgeUsername | cut -d':' -f2)
~/.bin/emails/MIMEmbellish | msmtp --user "$EMAIL" "$@" #EMAIL=$(pass Email/protonmail | grep BridgeUsername | cut -d':' -f2)
#~/.bin/emails/MIMEmbellish | msmtp --user "$EMAIL" "$@"
# Put the message, send to stdin, in a variable
message="$(cat -)"
config="$HOME/.config/msmtp/config.secret"
# Look at the first argument,
# Use it to determine the account to use
# If not set, assume work
# All remaining arguments should be recipient addresses which should be passed to msmtp
case "$(echo "$1" | tr '[A-Z]' '[a-z]')" in
"work") account="work"; shift ;;
"home") account="home"; shift ;;
*) account="work"; ;;
esac
cleanHeaders(){
# In the headers, delete any lines starting with markdown
cat - | sed '0,/^$/{/^markdown/Id;}'
}
echo "$message" | sed '/^$/q' | grep -q -i 'markdown: true' \
&& echo "$message" | cleanHeaders | convertToHtmlMultipart | msmtp --file="$config" --account="$account" "$@" \
|| echo "$message" | cleanHeaders | msmtp --file="$config" --account="$account" "$@"

Loading…
Cancel
Save