#!/bin/sh
#
# Plugin for FEddy
#
# For forwarding Fido-messages to other users on the same machine / network
#
# Needs "dialog" to run
# /dev/tty must be world- readable/writable
#
# Addressee can be given as first parameter
#
# Author: Andreas Foerster, 2:2448/655.8

# Formater
FORMAT=/usr/local/bin/utils/formatmsg

# Subject
SUBJECT="Forwarded Fido-Message"

# Temp-File:
TMP=/tmp/mailforward.tmp

#####

USER=$1

if [ -z "$USER" ]; then
   if dialog --title "Forward to mailsystem" \
             --inputbox "Username [@ System] :" 8 60 \
                   >/dev/tty </dev/tty 2>$TMP
   then
        USER=`cat $TMP`
   fi
   rm -f $TMP
fi

if [ -n "$USER" ]
then
     cat - | $FORMAT | mail -s "$SUBJECT" $USER
else
     cat - > /dev/null
fi


