[Roma.pm] Cancel old mail on mail server

Simone Spagna simone.spagna at gmail.com
Thu Dec 14 02:48:29 PST 2017


I've written this perl script to cancel oldest mail on a mail server.
But It dosn't work.
What's wrong?
Thanks in advance,
Simone

use Net::POP3;
use Date::Parse;
use strict;

my $host = "pop3.xxx.it <http://pop3.fondazioneboni.it>";
my $user = "simone.spagna\@xxx.it <http://fondazioneboni.it>";
my $pass = "xxxxyyy02";
my $max_age = 20*24*3600; # max allowed age in seconds

my $pop = Net::POP3->new($host) or die "cannot connect to mail server";
$pop->user($user );
my $msgs = $pop->pass($pass);
if ( $msgs )
{

my $now = time;
my $href = $pop->list();
foreach (keys %$href)
{

my $r = $pop->top( $_, 0 );

foreach (@$r)

{

next unless $_ =~ /^date:/i;

my($date) = $_ =~ /^date:\s+(.*)$/i;

my $time = str2time $date;

$pop->delete($_) if $now - $time >= $max_age;

}

}

}
$pop->quit();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/roma/attachments/20171214/14ccf5ad/attachment.html>


More information about the Roma mailing list