use strict;
use warnings;
use Net::POP3;

# ----- CONFIGURATION ------------------------------------------
use constant MAILHOST => "blackhole";     # Der POP3-Server
use constant MAILUSER => "saturn";        # POP3-Account
use constant MAILPASS => "saturn";        # oder User fragen
# ----- ab hier nichts mehr aendern ----------------------------

# Erzeuge ein POP3-Objekt
my $pop3 = Net::POP3->new(MAILHOST,'Timeout' => 60)
    or die "can't create a new pop3 object: $!\n";

# Beim POP3-Server einloggen
$pop3->login(MAILUSER, MAILPASS)
    or die "can't login to the pop3 server: $!\n";

my $anzahl = $pop3->list(); # hashref of i => size

foreach my $i (keys %$anzahl)
  {
  # Ausgabe der Nachricht auf dem Bildschirm
  # alternativ koennte auch in eine Datei ausgegeben werden
  print "Mail $i ...\n";
  my $msg = $pop3->get($i);
  print @$msg;
  print "\n";
  #       $pop3->delete($i);  # optional
  }

$pop3->quit;