/usr/share/doc/libmail-box-perl/examples/multipart.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 | #!/usr/bin/perl
# Print the types of messages in the folder. Multi-part messages will
# be shown with all their parts.
#
# 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;
sub show_type($;$);
#
# Get the command line arguments.
#
die "Usage: $0 folderfile\n"
unless @ARGV==1;
my $filename = shift @ARGV;
#
# 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;
#
# List all messages in this folder.
#
my @messages = $folder->messages;
print "Mail folder $filename contains ", scalar @messages, " messages:\n";
my $counter = 1;
foreach my $message (@messages)
{ printf "%3d. ", $counter++;
print $message->get('Subject') || '<no subject>', "\n";
show_type $message;
}
sub show_type($;$)
{ my $msg = shift;
my $indent = (shift || '') . ' '; # increase indentation
print $indent, " type=", $msg->get('Content-Type'), ', '
, $msg->size, " bytes\n";
if($msg->isMultipart)
{ foreach my $part ($msg->parts)
{ show_type $part, $indent;
}
}
}
#
# Finish
#
$folder->close;
|