#!/usr/local/bin/perl
#
# $Id: ffxrmail.pl,v 3.9.2.0 1995/06/12 17:14:03 mj Exp $
#
# sendmail frontend for processing ffx rmail commands
#

require "getopts.pl";
&Getopts('v');

# defaults
$PROTO    = "FFX";

#$SENDMAIL = "/usr/lib/sendmail -odq -oee -oMs$RELAY -oMr$PROTO";
$SENDMAIL = "/usr/lib/sendmail -odq -oee -oMr$PROTO";


# read From_ line from <STDIN>
$_ = <STDIN>;
if( /^From ([^ ]+) / ) {
    $from = $1;
}
else {
    die "ffxrmail: no From_ line at start of message\n";
}

# sendmail command
$cmd = "$SENDMAIL -f$from @ARGV";

print "CMD: $cmd\n" if($opt_v);

open(PIPE, "|$cmd") || die "ffxrmail: can't open pipe to sendmail\n";
while(<STDIN>) {
    print PIPE $_;
}
close(PIPE);
