#!/usr/bin/perl use strict; use warnings; use diagnostics; use Net::POP3; use Term::ReadKey; # Read the mail accounts from a file called addresses # which resides in the script's directory open ADDRESSES, "./addresses"; # read all the lines my @addys = ; # close address file close ADDRESSES; # do the following for every address foreach my $address (@addys) { # split address into username and hostname my ($user, $host) = $address =~ /(\S+)\s(\S+)/; # let the user enter his password print "Please enter the password for $user\@$host\:"; ReadMode( "noecho" ); my $pass = ReadLine(); ReadMode( "normal" ); print "\n"; # connect to host my $pop = Net::POP3->new( $host ) or do { print "Could not initialize connection.\n"; next; }; print "Connected to $host.\n"; # send USER my $msg_count = $pop->login( $user, $pass ) or do { print "Could not login.\n"; next; }; # print number of msg or complain about failed login if (defined $msg_count) { $pop->quit(); print "Messages: $msg_count\n"; } else { print "Login failed.\n"; } }