From 2895704eee6330cb549964de2d8b662040010fdd Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Sun, 16 Apr 2017 19:38:51 +0200 Subject: mcom: only generate multipart mime mails when using attachments --- mcom | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'mcom') diff --git a/mcom b/mcom index 3cfe028..03823b7 100755 --- 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= ;; -- cgit 1.4.1