/usr/share/doc/libmail-box-perl/examples/reply.pl is in libmail-box-perl 2.117-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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | #!/usr/bin/perl
# Demonstration on how to create a reply based on some message in
# some folder.
#
# Usage:
# ./reply.pl folder messagenr [signaturefile]
#
# This code can be used and modified without restriction.
# Mark Overmeer, <mailbox@overmeer.net>, 9 nov 2001
use warnings;
use strict;
use lib '..', '.';
use Mail::Box::Manager 2.00;
use Mail::Message::Body::Lines;
use Mail::Message::Construct;
#
# Get the command line arguments.
#
die "Usage: $0 folderfile messagenr [signaturefile]\n"
unless @ARGV==3 || @ARGV==2;
my ($filename, $msgnr, $sigfile) = @ARGV;
# You may create different kinds of objects to store body data, but
# usually the ::Lines object is ok. If you handle a body as 'reply'
# does, you want fast access to the separate lines. Preferably use
# ::File when the data is binary, and ::String when it is to be
# converted as a whole. Each type will work, but the performance will
# differ.
my $bodytype = 'Mail::Message::Body::Lines';
#
# Open the folder
#
my $mgr = Mail::Box::Manager->new;
my $folder = $mgr->open
( $filename
, extract => 'LAZY' # never take the body unless needed
); # which saves memory and time.
die "Cannot open $filename: $!\n"
unless defined $folder;
#
# Get the message to reply to
#
die "There are only ",scalar $folder->messages, " messages in $filename.\n"
if $msgnr > $folder->messages;
my $orig = $folder->message($msgnr);
#
# Create the reply prelude.
# The default only produces the replyPrelude line, but we extend it
# a little.
#
my $prelude = <<'PRELUDE';
Dear friend,
This automatically produced message is just a reply on yours. Please
do not be disturbed. Best wishes, Me, myself, and I.
PRELUDE
$prelude .= $orig->replyPrelude($orig->get('From')); # The usual quote line.
#
# The postlude is appended after the inlined source text. It is
# less visible than the prelude, because the quoted source text
# may be very long. However, when include is ATTACH on NO, the
# body is turned into one line, so this will be neat.
#
my $postlude = <<'POST';
Herewith, I reply to your message, and I intend to ignore it completely
unless you plan to complain to my boss about that.
See you (hope not)
POST
#
# Create a new signature
#
my $signature;
if(defined $sigfile)
{ $signature = $bodytype->new
( mime_type => 'text/x-vCard'
, file => $sigfile
);
}
else
{ $signature = $bodytype->new(mime_type => 'text/x-vCard', data => <<'SIG');
This is my signature. It is attached, in case we create
a multipart reply, and inlined otherwise.
SIG
}
#
# Create reply
# The original signature is stripped, the message is quoted, and a
# new signature is added.
#
my $reply = $orig->reply
( prelude => $prelude
, postlude => $postlude
, signature => $signature
);
# And now
$reply->print;
# or $reply->send;
$folder->close;
|