diff --git a/bin/.bin/emails/MIMEmbellish b/bin/.bin/emails/convertToHtmlMultipart similarity index 100% rename from bin/.bin/emails/MIMEmbellish rename to bin/.bin/emails/convertToHtmlMultipart diff --git a/bin/.bin/emails/send-from-mutt b/bin/.bin/emails/send-from-mutt index e80ff034..145d09b4 100755 --- a/bin/.bin/emails/send-from-mutt +++ b/bin/.bin/emails/send-from-mutt @@ -1,4 +1,27 @@ #!/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" "$@"