#!/usr/bin/perl $MAIL = '/var/qmail/bin/qmail-inject'; use Getopt::Std; getopts('f:m:s:b:B') or usage(); $opt_f or usage(); my $m_file = $opt_m; my $message; my $subj = $opt_s; @ARGV or usage(); my $to = join ', ', @ARGV; my $bcc = $opt_b || $ENV{FORGE_BCC} || $ENV{USER}; my $BCC = $opt_B ? "" : "Bcc: $bcc\n"; if ($m_file eq '-') { local $/; die "No subject specified; aborting" unless defined $opt_s; $message = ; } elsif ($m_file) { local $/; die "No subject specified; aborting" unless defined $opt_s; open M, "< $m_file" or die "Couldn't open file $m_file for reading: $!; aborting"; $message = ; close M; } else { unless (-t STDIN) { die "standard input not a terminal; use -m and -s options; aborting"; } unless (defined $opt_s) { print STDERR "Subject: "; chomp($subj = ); } print STDERR "Enter message on standard input; use . to terminate.\n"; while () { last if $_ eq ".\n"; $message .= $_; } } open M, "| $MAIL -f '$opt_f'" or die "Couldn't run $MAIL: $!; aborting"; print M <