#!/bin/sh
#
# queuemail - put standard input in a new file in /var/spool/out.going
# by Robert R Schneck
#
# This program takes an outgoing mail message on standard input
# and puts it in a new file in /var/spool/out.going
# for later sending with the `outmail' script
#
# Suggested use, if you use Pine as your mail agent: in .pinerc set
#   sendmail-path=/path/to/queuemail
# and then run `outmail' regularly.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
if name=$(mktemp /var/spool/out.going/`id -un`.`date +'%Y%m%d.%H%M%S'`.XXXXXXXXXX)
then
  echo "queuemail: Attempting to queue to $name..."
  if cat - > $name
  then
    echo "queuemail: Successfully queued to $name."
  else
    echo "queuemail: Failed to queue to $name!"
    exit 1
  fi
else
  echo "queuemail: mktemp failed ($name)!"
  exit 1
fi
