about summary refs log tree commit diff
path: root/mcom
diff options
context:
space:
mode:
Diffstat (limited to 'mcom')
-rwxr-xr-xmcom20
1 files changed, 11 insertions, 9 deletions
diff --git a/mcom b/mcom
index fb48401..4e834c6 100755
--- a/mcom
+++ b/mcom
@@ -236,7 +236,9 @@ esac
 hdrs="$(printf '%s\n' "${hdrs#$NL}" | mhdr -)"
 
 outbox=$(mhdr -h outbox "$MBLAZE/profile" | sed "s:^~/:$HOME/:")
-if [ -z "$outbox" ]; then
+draftbox=$(mhdr -h drafts "$MBLAZE/profile" | sed "s:^~/:$HOME/:")
+draftbox="${draftbox:-$outbox}"
+if [ -z "$draftbox" ]; then
 	if [ -z "$resume" ]; then
 		i=0
 		while [ -f "snd.$i" ]; do
@@ -249,13 +251,13 @@ if [ -z "$outbox" ]; then
 	draftmime="$draft.mime"
 else
 	if [ -z "$resume" ]; then
-		draft="$(true | mdeliver -v -c -XD "$outbox")"
+		draft="$(true | mdeliver -v -c -XD "$draftbox")"
 		if [ -z "$draft" ]; then
-			printf '%s\n' "$0: failed to create draft in outbox $outbox." 1>&2
+			printf '%s\n' "$0: failed to create draft in outbox $draftbox." 1>&2
 			exit 1
 		fi
 	elif [ -z "$draft" ]; then
-		draft=$(mlist -D "$outbox" | msort -r -M | sed 1q)
+		draft=$(mlist -D "$draftbox" | msort -r -M | sed 1q)
 	fi
 	draftmime="$(printf '%s\n' "$draft" | sed 's,\(.*\)/cur/,\1/tmp/mime-,')"
 fi
@@ -323,7 +325,7 @@ fi
 	*mbnc*)
 		old_ifs="$IFS"
 		IFS=$NL
-		set -- $(mseq -- "$@")
+		set -- $(mseq -r -- "$@")
 		IFS="$old_ifs"
 		if [ "$#" -ne 1 ]; then
 			printf 'mbnc: needs exactly one mail to bounce\n' 1>&2
@@ -343,13 +345,13 @@ fi
 		printf 'Resent-Date: %s\n' "$(mdate)"
 		(
 			IFS=$NL
-			cat $(mseq -- "$@")
+			cat $(mseq -r -- "$@")
 		)
 		;;
 	*mrep*)
 		old_ifs="$IFS"
 		IFS=$NL
-		set -- $(mseq -- "$@")
+		set -- $(mseq -r -- "$@")
 		IFS="$old_ifs"
 		if [ "$#" -ne 1 ]; then
 			printf 'mrep: needs exactly one mail to reply to\n' 1>&2
@@ -446,7 +448,7 @@ while :; do
 				if $sendmail <"$draftmime"; then
 					if [ "$outbox" ]; then
 						mv "$draftmime" "$draft"
-						mflag -d -S "$draft"
+						mrefile "$(mflag -d -S "$draft")" "$outbox"
 					else
 						rm "$draft" "$draftmime"
 					fi
@@ -464,7 +466,7 @@ while :; do
 				stampdate "$draft"
 				if $sendmail <"$draft"; then
 					if [ "$outbox" ]; then
-						mflag -d -S "$draft"
+						mrefile "$(mflag -d -S "$draft")" "$outbox"
 					else
 						rm "$draft"
 					fi