lig has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::POP3 question
by neilh (Pilgrim) on Oct 06, 2005 at 06:50 UTC | |
|
Re: Net::POP3 question
by PodMaster (Abbot) on Oct 06, 2005 at 10:45 UTC | |
|
Re: Net::POP3 question
by zentara (Cardinal) on Oct 06, 2005 at 11:53 UTC | |
|
Re: Net::POP3 question
by lig (Acolyte) on Oct 07, 2005 at 00:00 UTC |