From simone.spagna at gmail.com Thu Dec 14 02:48:29 2017 From: simone.spagna at gmail.com (Simone Spagna) Date: Thu, 14 Dec 2017 11:48:29 +0100 Subject: [Roma.pm] Cancel old mail on mail server Message-ID: 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 "; my $user = "simone.spagna\@xxx.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: