#!/usr/bin/perl -w
- EEST 2004
- Vidul N. P.
#
#`mail`-like script which takes as args strings
#or file without redirection:
#./mailer /etc/passwd or ./mail
http://nosuch.et
#because sm.th. it costs too much time to write
#recp addresses again and again
use strict;
use Env qw(USER);
use Net::SMTP;
###########
#conf vars#
my $myhost = 'zeus.et';
my @recp = qw(
root@pipi.et root@zeus.et arch@archiver.et);
my $debug = 1;
###########
my $sender = $ENV{USER};
my $smtp = Net::SMTP->new(
$myhost,
Hello => $myhost,
Timeout => 30,
Debug => $debug
);
$smtp->mail($sender);
$smtp->to(shift @recp);
$smtp->recipient(join ', ', split / /, "@recp", { SkipBad => 1 });
$smtp->data();
$smtp->datasend("n");
my $file = shift;
if(-f $file){
open FH, $file or die "$!";
my @file = <FH>;
close FH;
$smtp->datasend("@filen");
}else{
my $data = "$filen";
$data .= "$_n" for @ARGV;
print "$data";
$smtp->datasend("$datan");
}
$smtp->dataend();
$smtp->quit;