mblaze

Unix utilities to deal with Maildir - my mirror
git clone https://pi.duncano.de/git/mblaze.git
Log | Files | Refs | README | COPYING

commit 2895704eee6330cb549964de2d8b662040010fdd
parent ad9fe95761c4e1c4ac5430362747fd701887b9b3
Author: Leah Neukirchen <leah@vuxu.org>
Date:   Sun, 16 Apr 2017 19:38:51 +0200

mcom: only generate multipart mime mails when using attachments

Diffstat:
mcom | 25++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/mcom b/mcom @@ -23,6 +23,11 @@ msgdate() { mdate } +needs_multipart() { + mhdr -h attach "$1" >/dev/null || + grep -q '^#[^ ]*/[^ ]* ' "$1" +} + MBLAZE=${MBLAZE:-$HOME/.mblaze} sendmail=$(mhdr -h sendmail "$MBLAZE/profile") @@ -156,14 +161,20 @@ while :; do exit 1 ;; m|mime) - ( - IFS=' + if needs_multipart "$draft"; then + ( + IFS=' ' - msed '/attach/d' $draft - for f in $(mhdr -M -h attach $draft); do - printf '#%s %s\n' "$(file -Lbi $f | sed 's/ //g')" "$f" - done - ) | mmime >$draftmime + msed '/attach/d' $draft + for f in $(mhdr -M -h attach $draft); do + printf '#%s %s\n' \ + "$(file -Lbi $f | sed 's/ //g')" \ + "$f" + done + ) | mmime >$draftmime + else + mmime -r <"$draft" >"$draftmime" + fi mshow -t $draftmime c= ;;