/usr/share/doc/libemail-send-perl/examples/send-email.pl is in libemail-send-perl 2.198-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | #!/usr/bin/perl
use strict;
$^W = 1;
use Email::Send;
use Getopt::Long;
GetOptions my $options = {
header => {},
body => [],
}, 'via=s',
'to=s@', 'from=s', 'cc=s@', 'bcc=s@',
'subject=s',
'header=s%',
'body=s@',
'dump';
my $sender = $options->{via} or die "No Sender set with -via\n";
my @sargs = @ARGV;
my @headers;
push @headers, "From: $options->{from}" if $options->{from};
foreach (qw[to cc bcc]) {
next unless $options->{$_} && @{$options->{$_}};
push @headers, join ': ',
ucfirst($_),
join(', ', @{$options->{$_}});
}
push @headers, "Subject: $options->{subject}" if $options->{subject};
while (my($k,$v) = each %{$options->{header}}) {
push @headers, "$k: $v";
}
my $body = join "\r\n", @{$options->{body}};
$body = join "\r\n", map {chomp; $_} <STDIN> unless $body;
my $message = join "\r\n", join("\r\n", @headers, ''), $body, '';
print join $message, (join(' Message ', ('-'x20)x2) . "\n")x2
if $options->{dump};
print "Send Command: Email::Send->new({
mailer => '$sender',
mailer_args => [". join(', ', map "'$_'", @sargs) ."],
})->send(\$message);\n" if $options->{dump};
my $mailer = Email::Send->new({
mailer => $sender,
mailer_args => \@sargs,
});
my $rv = $mailer->send($message);
if ( $options->{dump} ) {
use Data::Dumper;
print "Email::Send::send() results: " . Dumper $rv;
}
__END__
=pod
=head1 NAME
send-email.pl - Simple program that helps test senders
=head1 SYNOPSIS
send-email.pl -via Sender
-to Address
-from Address
-cc Address
-bcc Address
-subject 'Subject Line'
-header Key=Value
-body Line
Sender Args
=head1 EXAMPLE
perl ./send-email.pl -via SMTP
-header X-Test=hello
-to 'casey@example.com'
-from 'casey@example.com'
-body "Hi there"
-body "New Line"
mx.example.com Debug 1
|