I am trying to learn how to receive and send mail with Perl from a web browser. Have been reading the Perl Cookbook to get a general feel for it by reading/learning about CGI and Net::POP3. Everything has been going pretty well until I actually tried to connect to the POP server.

I keep getting various error messages (that to me at least are not informative) returned. The error is occuring on the constructor for the POP3 object.

Particulars:
code is taken almost verbatim from the Perl Cookbook.

# use strict, warnings and diagnostics # retrieve the pop3 messages eval { print $page -> p(qw(We are going to retrieve the emails here since + you told us to do that.)), "\n"; # open a connection my $pop = Net::POP3->new(Host=>"pop.gmail.com:995") or die("Can't connect to the POP3 server: $! \n"); # log in defined($pop->apop('myaccount@gmail.com', 'mypass')) or die("Couldn't authenticate: $! \n"); # get the message list my $messageList = $pop->list() or die("Couldn't retreive message list: $! \n"); # for each of the messages foreach my $msgid (keys %$messageList) { my $message = $pop->get($msgid); if(defined($message)) { print $message; } else { warn ("Couldn't retreive message. msgId# $msgid"); next; } } }; if ($@) { print "Error occured $@ \n"; }

<Error message returned>
Error occured Can't connect to the POP3 server: Bad file descriptor
</Error message returned>

If I change the POP3 server to something like mail.domain.com, I get the error "Invalid Arguement" rather then Bad file descriptor. I have also tried it with and without the port number (or at least I think that is how you tell it which port to go to) with the same results.

I have read over the Net::POP3 docs on CPAN, reread the "Discussion" provided in Perl Cookbook and still can not figure out where I went wrong. Ideas, Hints, and Suggestions are always greatly appreciated.

life is a game... so have fun.

In reply to Net::POP3 question by lig

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.