Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

This being my first experience with Net::POP3 I'm having some difficulty getting into my mail server. I talked with my web host this morning and they confirmed my account username and the mail server are correct.

I don't receive any errors but the only output is "could not connect to email. Below is the entire code, pretty much copied and pasted from the Net::POP3 page on Cpan itself.

Anyone out there have experience with this module see what I'm doing wrong?
#!/usr/bin/perl use warnings; use strict; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); print header, start_html('test'); my $email_user = 'email@domain.com; my $email_pass = 'pass'; my $email_server = 'mail.domain.com'; use Net::POP3; my $pop = Net::POP3->new($email_server); if ($pop->login($email_user, $email_pass) > 0) { my $msgnums = $pop->list; # hashref of msgnum => size foreach my $msgnum (keys %$msgnums) { my $msg = $pop->get($msgnum); print @$msg; $pop->delete($msgnum); } print "Logged in"; } else { print "Could not connect to email"; } $pop->quit;

Replies are listed 'Best First'.
Re: Net::POP3 doesn't connect
by marto (Cardinal) on Mar 18, 2011 at 13:14 UTC

    Enable debugging as mentioned in Net::POP3:

    my $pop = Net::POP3->new($email_server, Debug=>1) or die "Can't connec +t to $email_server: $! \n";
      Hi.

      Thank you for the response. I added the code exactly how you had it and it made no difference in the output. The only output is mine saying it can't connect to the server.

      Any other ideas?

        You seem to be running this as a CGI script... so you might want to look in the webserver's error_log, because (AFAIK) the debug prints will go to STDERR.

        Alternatively, redirect STDERR to STDOUT, so the debug messages will also be sent to the browser.  I.e. modify your script as follows:

        #!/usr/bin/perl use warnings; use strict; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser carpout); carpout(\*STDOUT); ...
Re: Net::POP3 doesn't connect
by Eliya (Vicar) on Mar 18, 2011 at 13:10 UTC

    Running it in debug mode might give some clue...

    my $pop = Net::POP3->new($email_server, Debug => 1);