#!/usr/bin/perl -w
######################################################################
# pop3.pl
######################################################################
# Perl Power! - Michael Schilli 1998
######################################################################

use Net::POP3;
######################################################################
$host   = 'my.mail.host';           # mail host
$userid = 'huber';                  # login
$passwd = 'nixgibts!';              # password
######################################################################

                                    # contact host
($mail = Net::POP3->new($host)) || die "Could not open $host";

                                    # login
$nof_messages = $mail->login($userid, $passwd);
die "Userid/Passwd Error" unless defined $nof_messages;

if($nof_messages) {                 # are there any messages?
                                    # for all messages
    foreach $mesgno (keys %{$mail->list()}) {
                                    # scour all header lines
        foreach (@{$mail->top($mesgno)}) {
            $subject = $1 if /^Subject: (.*)/;
            $from    = $1 if /^From: (.*)/;
        }

        printf "%02d %-30s %s\n", $mesgno, $from, $subject, "\n";
    }
}

$mail->quit();                      # exit mail program

