trusted_users = mail:www-data #### #!/usr/bin/perl -w use strict; use Mail::Mailer; use Getopt::Std; use vars qw( %opts $line $user $body ); getopts('f:t:s:h', \%opts); $user = getpwuid($<); sub usage() { print <) { last if ($line =~ /^\.$/); $body .= $line; } sendmail ($opts{'f'}, $opts{'t'}, $opts{'s'}, $body); print "Mail Sent.\n"; exit; sub sendmail { my ($from, $to, $subject, $body) = @_; my $mailer; eval { $mailer = Mail::Mailer->new('sendmail'); }; if ($@) { warn "Couldn't send mail: $@"; } else { $mailer->open({ To => $to, From => $from, Subject => $subject }); print $mailer $body; unless (close ($mailer)) { warn "Couldn't close mailer: $!"; } } }