/usr/share/doc/libnet-imap-perl/examples/imap.pl is in libnet-imap-perl 0.02-9.
This file is owned by root:root, with mode 0o755.
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 | #!/usr/bin/perl -wI..
# This example script illustrates basic use of the Net::IMAP module.
# It shows how commands are issued, how the responses are checked, and
# how to configure callbacks to process data retrieved from the
# server.
# It assumes the use of the the University of Washington imap daemon,
# or any imap daemon that allows tty interaction with the daemon when
# invoked from the comand line.
use Net::IMAP;
my $host = '/usr/sbin/imapd';
my $imap = new Net::IMAP($host, Debug => 0)
or die("can't connect to $host: $!\n");
$imap->set_untagged_callback('namespace', \&do_namespace);
$response = $imap->noop
or die("noop failed");
print "noop returned: ", $response->status, "\n";
print "noop text: ", $response->text, "\n";
if ($imap->has_capability('namespace')) {
$response = $imap->namespace
or die("namespace command failed");
} else {
warn("server doesn't implement namespace extension");
}
$response = $imap->logout
or die "error sending logout: $!";
sub do_namespace {
my $self = shift;
my $resp = shift;
print "Namespaces\n";
print " Personal:\n";
for my $item (sort $resp->personal) {
printf(" %-12s %s\n", $item, $resp->personal($item));
}
print " Other Users:\n";
for my $item (sort $resp->other_users) {
printf(" %-12s %s\n", $item, $resp->other_users($item));
}
print " Shared:\n";
for my $item (sort $resp->shared) {
printf(" %-12s %s\n", $item, $resp->shared($item));
}
}
|