aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-04-16 19:38:51 +0200
committerLeah Neukirchen <leah@vuxu.org>2017-04-16 19:38:51 +0200
commit2895704eee6330cb549964de2d8b662040010fdd (patch)
treecbc8a9008dd8c448bcf37e95ed0bb12ffa13d144
parentad9fe95761c4e1c4ac5430362747fd701887b9b3 (diff)
downloadmblaze-2895704eee6330cb549964de2d8b662040010fdd.tar.gz
mcom: only generate multipart mime mails when using attachments
-rwxr-xr-xmcom25
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=
;;