blob: 5f00651f592c73988a82f623bd33b1cf77313ddb (
plain) (
tree)
|
|
#!/usr/bin/perl
use strict;
use warnings;
use Mail::IMAPClient;
use Data::Dumper;
use DateTime;
my $hostname = "localhost";
my $login = "matej";
my $passwd = "lubdkc";
die "Just one name of the folder, please." unless $#ARGV == 0;
# How many months before today the cut date should be?
my $howManyMonths = 3;
my $lengthOfScreen = 65;
my $imap = Mail::IMAPClient->new();
$imap = Mail::IMAPClient->new(
Server => $hostname,
User => $login,
Password => $passwd,
UID => 1
) or die "Cannot connect to localhost as matej: $@";
my $cutDate = DateTime->now();
$cutDate->add( months => -$howManyMonths );
# Do the stuff!
$imap->select($ARGV[0]);
my @msgsProc = $imap->search(" UNDELETED BEFORE " . $cutDate->strftime("%d-%b-%Y"));
print "\$#msgsProc = $#msgsProc\n";
$imap->delete_message(@msgsProc) or die "Cannot delete $#msgsProc messages.";
$imap->close();
|