#!/bin/sh
#
# getmail :		This sends outbound mail to our remote term host for
#              delivery on the Internet. Since we don't have access
#              to network DNS all mail not destined for our local
#              domain is held in a queue until we connect.
#               
# Last modified: 05/01/95
#
# Author: David J. Lennox  < djlennox#mtu.edu >
#
#
#
REMOTE="djlennox"  # Replace with your remote login name.

#
# Change to our queue directory and check for outgoing mail.
#

cd /var/spool/mqueue

for i in *qf*
do
  if [ ! -f /var/spool/mqueue/$i  ]
  then
    echo "No mail in queue...."
    exit 0
  fi
done    ###  If no mail in queue exit.  ###

#
# If outbound mail is found change to a temporary directory and send mail.
#
# NOTE: The following routine is for people who run as root on their
#       local machine. This routine checks each header file in the
#       queue directory for the name "root" and changes this name to
#       the name used for receiving mail on the remote host. This will
#       enable the "Reply-To:" function of the mail system to forward
#       replies to the correct address. This will also keep the 
#       administrator at the remote host from receiving error messages
#       about your mail. If you run as root un-comment the following
#       commented lines.
#                            

#cd /var/spool/tmp
#cp /var/spool/mqueue/*qf* /var/spool/tmp

# for i in *qf*
# do
#   sed -e /root/s//${REMOTE}/ /var/spool/mqueue/$i > /var/spool/tmp/$i
# done
#
# mv -f *qf* /var/spool/mqueue
# cp /var/spool/mqueue/*qf* /var/spool/tmp
#
# for i in *qf*
# do
#   sed -e /"<root>"/s//"<${REMOTE}>"/ /var/spool/mqueue/$i > /var/spool/tmp/$i
# done
#
# mv -f *qf* /var/spool/mqueue

#
# Change to queue directory and send mail.
#

cd /var/spool/mqueue

for i in *qf*
do
if [ -f $1 ]
then
  echo "Sending Mail Queue...."
  /usr/sbin/sendmail -q
  exit 0
fi
done


# Done!
