frostman has asked for the wisdom of the Perl Monks concerning the following question:
Monks,
I'm having trouble with both Net::POP3 and Mail::POP3Client.
I think I'm doing everything "right" - see code at bottom. However...
With Net::POP3 I get strange errors in $!. As far as I could tell from available online docs, that's where it's putting error messages. For connection errors it seems fine, but on authentication errors I get weirdness: for example, when the POP3 server returns the error "-ERR Username/Password Mismatch perhaps foo@yourdomain.com ?" I get "Bad file descriptor" in $!.
I really need to capture this info.
Does anyone know a better/more reliable way to access the *actual* error return value from the POP3 server in Net::POP3?
Hoping it would be easier with Mail::POP3Client, which at least has Message(), I tried that... and found that I get a "Broken pipe" error if I try to connect to my *local* POP3 server, while it works fine if the server is remote.
I can work around that, since in this case I'm only checking external servers, but it seems very inelegant... and who knows, maybe I've even found a bug in Mail::POP3Client ;-)
Any pointers are much appreciated. For now I'm going to just have to use a workaround. :-(
(I'm running Perl 5.6.1 on RedHat7.2, and CPAN-installed these modules a few days ago.)
CODE SAMPLES:
Mail::POP3Client:
# POP3Client dies with "Broken pipe" and nothing else. # (works fine with external server) use strict; use Mail::POP3Client; my $pop3 = new Mail::POP3Client( HOST => "localhost" ); $pop3->User( "somebody" ); $pop3->Pass( "doublesecret" ); $pop3->Connect() || die "failed: " . $pop3->Message() . "\n"; $pop3->Close();
Net::POP3:
# Host is valid, user/pass are not. use strict; use Net::POP3; my $host = 'biztos.com'; # valid POP3 host, feel free to test against +it. my $user = 'foobar'; # nonexistent user my $pass = 'badpass'; # dummy password my $pop3 = Net::POP3->new($host,Timeout => 30,Debug => 1); die "connect failed: $!\n" unless $pop3; # this works fine. # try apop first: my $apop_messages = $pop3->apop($user,$pass); if ($apop_messages) { $pop3->quit(); print "apop ok.\n"; } else { print "apop didn't work, trying login ($!)\n"; # the above $! is "No such file or directory" # ...and debug didn't show anything, so I'm assuming # apop() just skipped it due to presumed incompatibility. # on my localhost it shows the apop transaction. my $pop_message = $pop3->login($user,$pass); if ($pop_message) { $pop3->quit(); print "login ok.\n"; } else { $pop3->quit(); die "login failed: $!\n"; # the above $! is "Bad file descriptor" but the # POP3 server said: # "-ERR Username/Password Mismatch perhaps foobar@yourdomain.c +om ?" } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::POP3 and Mail::POP3Client Weirdness - argh!
by Mr. Muskrat (Canon) on Apr 17, 2003 at 17:18 UTC | |
by Anonymous Monk on Jul 14, 2003 at 15:48 UTC | |
by Mr. Muskrat (Canon) on Jul 14, 2003 at 16:43 UTC | |
by Anonymous Monk on Jul 15, 2003 at 16:57 UTC | |
by Mr. Muskrat (Canon) on Jul 15, 2003 at 17:00 UTC | |
|
Re: Net::POP3 and Mail::POP3Client Weirdness - argh!
by zentara (Cardinal) on Apr 18, 2003 at 15:30 UTC |