#!/bin/sh
# The original idea of using MH (namely, comp) to send mail from nn
# came from Jaap Vermeulen <jaap@sequent.com>, but he wouldn't
# recognize what I did to it.  I also used a suggestion from John
# Romine <jromine@ics.uci.edu> and Tom McCain <tom@dynamo.ecn.purdue.edu>.
#
# Add
#
#       set mail-script nn-use-mh
#
# to your init file.  See Appendix "nn-use-mh" for the script.

# Edited to honor the edit request by Brian Exelbierd (bex@ncsu.edu)

# Obtain value of $WORK and $RECORD
. ${HOME}/.nn/.param

# Append Fcc: +folder to headers.  The folder is specified in
# mail-record.
if [ "$RECORD" != "" ]; then
      awk '
      {
	      if ($0 == "" && !done) {
		      print "Fcc: +'$RECORD'";
		      done = 1;
	      }
	      print;
      }' $WORK > /tmp/aux.$$ && mv /tmp/aux.$$ $WORK
fi

if [ "$FIRST_ACTION" = "send" ]; then
	send $WORK
	rm -f ,$WORK
else
	# Compose and send the mail
	comp -form $WORK
	rm -f $WORK
fi

