#
# Emulation of compiled mhmail(1) using nmh send(1) or post(8).
# Differences from compiled mhmail:
-# * Supports all send(1) (with -profile) or post(8) (without -profile) options.
+# * Supports all post(8) (by default, without -profile) or send(1)
+# (with -profile) options.
# * Optionally (with -profile) obeys the users profile, including
# AliasFile and send entries.
# * Adds -debug option for debugging (sending, not incorporating new mail).
cclist="${cclist:+${cclist}, }${arg}"; ccarg=0
elif [ ${bodyarg} -eq 1 ]; then
body=${arg}; bodyarg=0
+ #### Allow -body "" by using just a newline for the body.
+ [ "${body}"x = x ] && body="
+"
elif [ ${otherarg} -eq 1 ]; then
#### Always end ${header} with a newline.
header="${header:+${header} }${arg}
"
fi
+ #### If no -body, read message from stdin the easy way.
+ [ "${body}"x = x ] && body=`cat`
+ #### Don't allow an empty body (from stdin).
+ [ "${body}"x = x ] && exit 1
+
#### Set up a tmpfil and trap to remove it. send moves the file to a backup.
tmpdir=${MHTMPDIR:-${TMPDIR:-${TMP:-`${nmhbindir}/mhpath +`}}}
tmpfil=${tmpdir}/mhmail$$