about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-06-18 17:48:24 +0200
committerLeah Neukirchen <leah@vuxu.org>2017-06-18 17:48:24 +0200
commit2939be9f34b400fa59cb12c59c2c101c852fea92 (patch)
tree6ba7822a45584666ae967ffe9c070af667576bdf
parent01ad9ec927a6ec1b4acbce2a7e3b48135fa794e4 (diff)
downloadmblaze-2939be9f34b400fa59cb12c59c2c101c852fea92.tar.gz
mblaze-2939be9f34b400fa59cb12c59c2c101c852fea92.tar.xz
mblaze-2939be9f34b400fa59cb12c59c2c101c852fea92.zip
mcom: add mfwd command to forward messages
-rw-r--r--GNUmakefile1
-rw-r--r--man/mcom.115
-rwxr-xr-xmcom30
3 files changed, 45 insertions, 1 deletions
diff --git a/GNUmakefile b/GNUmakefile
index 3389143..61e8dfb 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -56,6 +56,7 @@ install: FRC all
 	install -m0755 $(ALL) $(SCRIPT) $(DESTDIR)$(BINDIR)
 	ln -sf mless $(DESTDIR)$(BINDIR)/mnext
 	ln -sf mless $(DESTDIR)$(BINDIR)/mprev
+	ln -sf mcom $(DESTDIR)$(BINDIR)/mfwd
 	ln -sf mcom $(DESTDIR)$(BINDIR)/mrep
 	install -m0644 man/*.1 $(DESTDIR)$(MANDIR)/man1
 	install -m0644 man/*.5 $(DESTDIR)$(MANDIR)/man5
diff --git a/man/mcom.1 b/man/mcom.1
index 6e2ce0e..1bee90a 100644
--- a/man/mcom.1
+++ b/man/mcom.1
@@ -3,11 +3,15 @@
 .Os
 .Sh NAME
 .Nm mcom ,
+.Nm mfwd ,
 .Nm mrep
-.Nd compose new, reply to, and send mail
+.Nd compose new, forward, reply to, and send mail
 .Sh SYNOPSIS
 .Nm mcom
 .Op Ar recipient
+.Nm mfwd
+.Op Fl r
+.Op Ar msgs\ ...
 .Nm mrep
 .Ar msg
 .Sh DESCRIPTION
@@ -16,6 +20,15 @@ creates a new draft mail and runs an editor.
 After editing, a loop is started where the user can re-edit, send or
 cancel the mail.
 .Pp
+.Nm mfwd
+behaves like
+.Nm mcom
+but fills the draft with subject and body prefilled to forward the messages.
+By default, messages are forwarded verbatim as MIME attachments.
+Use
+.Fl r
+to forward as rendered plain text, using RFC934 message encapsulation.
+.Pp
 .Nm mrep
 behaves like
 .Nm mcom
diff --git a/mcom b/mcom
index 07f25f8..9fea4c6 100755
--- a/mcom
+++ b/mcom
@@ -67,6 +67,35 @@ fi
 		msgdate
 		printf '\n\n'
 		;;
+	*mfwd*)
+		raw=
+		[ "$1" = -r ] && raw=1 && shift
+		[ "$#" -eq 0 ] && set -- .
+		printf '%s: \n' To Cc Bcc
+		mscan -f 'Subject: [%f] %s' "$@" | sed 1q
+		from=$(mhdr -h local-mailbox "$MBLAZE/profile")
+		[ "$from" ] && printf 'From: %s\n' "$from"
+		cat "$MBLAZE/headers" 2>/dev/null
+		msgid
+		museragent
+		msgdate
+		printf '\n\n'
+		if [ -n "$raw" ]; then
+			mseq -r "$@" | sed 's:^:#message/rfc822 :'
+		else (
+			SEP=-----
+			IFS='
+'
+			for f in $(mseq -r "$@"); do
+				printf '%s Forwarded message from %s %s\n\n' \
+				       $SEP "$(mhdr -d -h from "$f")" $SEP
+				DISPLAY= mshow -n -N "$f" </dev/null |
+					sed 's/^-/- &/'    # RFC934
+				printf '\n%s %s %s\n\n' \
+				       $SEP 'End forwarded message' $SEP
+			done
+		) fi
+		;;
 	*mrep*)
 		[ "$#" -eq 0 ] && set -- .
 		ng=$(mhdr -h newsgroups "$1")
@@ -100,6 +129,7 @@ fi
 
 		mquote "$1"
 		printf '\n'
+		;;
 	esac
 
 	if [ -f "$MBLAZE/signature" ]; then