diff options
author | Leah Neukirchen <leah@vuxu.org> | 2017-04-16 19:38:51 +0200 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2017-04-16 19:38:51 +0200 |
commit | 2895704eee6330cb549964de2d8b662040010fdd (patch) | |
tree | cbc8a9008dd8c448bcf37e95ed0bb12ffa13d144 /mcom | |
parent | ad9fe95761c4e1c4ac5430362747fd701887b9b3 (diff) | |
download | mblaze-2895704eee6330cb549964de2d8b662040010fdd.tar.gz mblaze-2895704eee6330cb549964de2d8b662040010fdd.tar.xz mblaze-2895704eee6330cb549964de2d8b662040010fdd.zip |
mcom: only generate multipart mime mails when using attachments
Diffstat (limited to 'mcom')
-rwxr-xr-x | mcom | 25 |
1 files changed, 18 insertions, 7 deletions
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= ;; |