File: imap2.pl

package info (click to toggle)
libnetxap-perl 0.02-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 184 kB
  • ctags: 276
  • sloc: perl: 1,600; makefile: 48
file content (29 lines) | stat: -rwxr-xr-x 692 bytes parent folder | download | duplicates (6)
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
#!/usr/bin/perl -wI..

# This example illustrates using a callback to process "list" data.

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('list', \&do_list);

$response = $imap->list('~/Mail/', '%')
  or warn("failed sending list command");
if ($response->status ne 'ok') {
  warn("list command returned ",
       $response->status, " ", $response->text, "\n");
}

$response = $imap->logout or die "error sending logout: $!";

sub do_list {
	my $self = shift;
	my $resp = shift;
	print "List: ", join(',', $resp->mailbox,
				  $resp->delimiter,
				  $resp->flags), "\n";
}