sub get_newsletters { # ---------------------------------------------------------------- # my $self = shift; my $dbh = $self->param('dbh'); use Net::POP3; my $pop = Net::POP3->new('mail.foo.bar', Timeout => 60); my $username = "foo"; my $password = "bar"; my (@messages); if ($pop->login($username, $password) > 0) { my $msgnums = $pop->list; # hashref of msgnum => size foreach my $msgnum (keys %$msgnums) { my %row; my $msg = $pop->get($msgnum); $row{id} = $msgnum; $row{email} = @$msg; warn "print $row{id} - @$msg"; # $pop->delete($msgnum); push (@messages,\%row); } } $pop->quit; my $tmpl_path = "view_emails.shtml"; my $tmpl = $self->load_tmpl($tmpl_path, die_on_bad_params => 0); $tmpl->param ( messages => \@messages, ); $self->_set_username_in_tmpl(\$tmpl); return $tmpl->output; }