/usr/share/doc/libmailtools-perl/demos/send_demo is in libmailtools-perl 2.18-1.
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 | #!/usr/bin/perl -w
require Mail::Internet;
require Mail::Alias;
use Getopt::Long;
sub expand_aliases
{
my $mail = shift;
my $aliasfile = $ENV{HOME} . "/.mailrc";
my($tag,$id);
if( -f $aliasfile )
{
my $alias = Mail::Alias::Binmail->new($aliasfile);
# Expand aliases
foreach $tag (qw(To Cc Bcc))
{
@ids = ();
foreach $id (Mail::Address->parse($mail->get($tag)))
{
my $addr = $id->address;
my @expn = $alias->expand($addr);
if(scalar(@expn) == 1)
{
$id->address($expn[0]);
push(@ids,$id->format);
}
else
{
push(@ids,@expn);
}
}
$mail->combine($tag,',');
$mail->replace($tag, join(", ", @ids));
}
}
}
###
### Main program
###
GetOptions(qw(post nosig v));
$opt_post = 1 if $0 =~ m#(\A|/)post\Z#;
$verbose = defined $opt_v && $opt_v ? 1 : 0;
$posting = defined $opt_post && $opt_post ? 1 : 0;
$sign = defined $opt_nosig && $opt_nosig ? 0 : 1;
$mail = Mail::Internet->new([ <> ]);
expand_aliases($mail);
$mail->add_signature if($sign);
if($posting)
{
my @groups = $mail->nntppost();
if($verbose && @groups)
{
$groups = "Newsgroups: " . join(", ", @groups);
$groups =~ s/(.{10,78}),/$1\n/g if(length($groups) > 78);
print $groups,"\n";
}
}
else
{
$mail->delete('Newsgroups');
}
@recp = $mail->smtpsend();
if($verbose && @recp)
{
$recp = "Recipients: " . join(", ", @recp);
$recp =~ s/(.{10,78}),/$1\n/g if(length($recp) > 78);
print $recp,"\n";
}
exit;
|