The base64-decoder doesn't work on 64-bit big-endian architectures:
[mmh] / uip / mhmail.in
index d2d9d26..56bcac0 100755 (executable)
@@ -8,7 +8,8 @@
 #
 # 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).
@@ -83,6 +84,9 @@ else
            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}
@@ -102,11 +106,16 @@ else
   fi
   if [ "${havefrom}" = 0 ]; then
     nmhlibdir=`${nmhbindir}/mhparam libdir`
-    header="${header:+${header}
-}From: "`${nmhlibdir}/ap -format '%(localmbox)' 0`"
+    header="${header:+${header}}From: "\
+`${nmhlibdir}/ap -format '%(localmbox)' 0`"
 "
   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$$