I have a few alternative mail accounts, mostly used when I need to register with a site I don't trust and thus when I'm expecting spam. Checking last night, I noticed that 3 accounts were filled up with a grand total of 3500 spams, so I wrote a small Perl script, using Net::POP3, to delete all mails in an account.
-
#!/usr/bin/perl
-
use Net::POP3;
-
if (@ARGV <2) {
-
print "Usage : $0 <login> <pass>\n";
-
exit 0;
-
}
-
-
print "Going to delete ALL mail from account $ARGV[0] ! ctrl-c to abort\n";
-
-
sleep 3;
-
$pop = Net::POP3->new('pop.free.fr');
-
die "Couldn’t log on to server" unless $pop;
-
-
$total = $pop->login($ARGV[0],$ARGV[1]);
-
die "No mails or couldn’t connect !" unless $total;
-
-
print("Deleting $total mails ...\n");
-
-
for($i = 0; $i<$tot; $i++) {
-
$pop->delete($i);
-
}
-
-
$pop->quit();
-
-
exit 1;
said, on 08/Jan/05 at 6:16 pm # :
cool. perhaps adding the POP server as a third argument would be a good idea...
commented, on 21/Feb/05 at 10:53 pm # :
Nice script, but has a little error:
for($i = 0; $i
thought, on 21/Feb/05 at 11:44 pm # :
Hmm, what is the error then ? Works fine for me :)
replied, on 04/Jul/06 at 6:01 am # :
The error is that the for loop variable is "$tot" where it should be "$total"