about summary refs log tree commit diff
path: root/mcom
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-06-29 14:31:02 +0200
committerLeah Neukirchen <leah@vuxu.org>2017-06-29 14:31:02 +0200
commit2db5551a7e3b9820780266d79865b9c2a94df81c (patch)
tree127aad4879e3788a71ebeb9d42a71b6631627a0b /mcom
parent862d6b24e414e780c5f641bab9586b102ba908e9 (diff)
downloadmblaze-2db5551a7e3b9820780266d79865b9c2a94df81c.tar.gz
mblaze-2db5551a7e3b9820780266d79865b9c2a94df81c.tar.xz
mblaze-2db5551a7e3b9820780266d79865b9c2a94df81c.zip
mcom: add Date: header before submission, or when cancelling a draft
Diffstat (limited to 'mcom')
-rwxr-xr-xmcom19
1 files changed, 13 insertions, 6 deletions
diff --git a/mcom b/mcom
index f06da6f..0a3d219 100755
--- a/mcom
+++ b/mcom
@@ -20,9 +20,16 @@ msgid() {
 	mgenmid 2>/dev/null | sed 's/^/Message-Id: /'
 }
 
-msgdate() {
-	printf 'Date: '
-	mdate
+stampdate() {
+	if ! mhdr -h date "$1" >/dev/null; then
+		tmp=$(mktemp -t mcom.XXXXXX)
+		{
+			printf 'Date: '
+			mdate
+			cat "$1"		
+		} >"$tmp" &&
+		mv "$tmp" "$1"
+	fi
 }
 
 needs_multipart() {
@@ -88,7 +95,6 @@ fi
 		cat "$MBLAZE/headers" 2>/dev/null
 		msgid
 		museragent
-		msgdate
 		printf '\n\n'
 		;;
 	*mfwd*)
@@ -102,7 +108,6 @@ fi
 		cat "$MBLAZE/headers" 2>/dev/null
 		msgid
 		museragent
-		msgdate
 		printf '\n\n'
 		if [ -z "$raw" ]; then
 			mseq -r "$@" | sed 's:^:#message/rfc822#inline :; s:$:>:'
@@ -148,7 +153,6 @@ fi
 		fi
 		msgid
 		museragent
-		msgdate
 		printf '\n'
 
 		mquote "$1"
@@ -179,6 +183,7 @@ while :; do
 
 		if [ -e $draftmime ]; then
 			if [ $draft -ot $draftmime ]; then
+				stampdate $draftmime
 				if $sendmail <$draftmime; then
 					if [ "$outbox" ]; then
 						mv $draftmime $draft
@@ -197,6 +202,7 @@ while :; do
 			fi
 		else
 			if mmime -c <$draft; then
+				stampdate $draft
 				if $sendmail <$draft; then
 					if [ "$outbox" ]; then
 						mflag -d $draft
@@ -215,6 +221,7 @@ while :; do
 		fi
 		;;
 	c|cancel)
+		stampdate $draft
 		printf '%s\n' "mcom: cancelled draft $draft"
 		exit 1
 		;;