File: cyrus_expunge.pl

package info (click to toggle)
libmail-imapclient-perl 2.1.4-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,236 kB
  • ctags: 231
  • sloc: perl: 11,273; makefile: 56
file content (30 lines) | stat: -rw-r--r-- 855 bytes parent folder | download
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
#!/usr/local/bin/perl

use Mail::IMAPClient;
use IO::File;

# Change the following line (or replace it with something better):
my($h,$u,$p) = ('cyrus_host','cyrus_admin_id','cyrus_admin_pswd');

my $imap = Mail::IMAPClient->new(	Server  => "$h",			# imap host
					User    => "$u",			# $u,	
					Password=> "$p",			# $p,
					Uid	=> 1,				# True value
					Port    => 143,				# Cyrus
					Debug	=> 0,				# True value
					Buffer	=> 4096*10,			# True value
					Fast_io	=> 1,				# True value
					Timeout	=> 30,				# True value
					# Debug_fh=> IO::File->new(">out.db"),	# fhandle
				) 
or die "$@";

for my $f ( $imap->folders ) {
	print "Expunging $f\n";
	unless ($imap->select($f) ) {
		$imap->setacl($f,$u,"lrswipcda") or warn "Cannot setacl for $f: $@\n" and next;
		$imap->select($f) or warn "Cannot select $f: $@" and next;
	}
	$imap->expunge;
}