Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Checking muliptle mailboxes on same server with Net::POP3

by Popcorn Dave (Abbot)
on Apr 13, 2007 at 00:05 UTC ( #609793=perlquestion: print w/replies, xml ) Need Help??

Popcorn Dave has asked for the wisdom of the Perl Monks concerning the following question:

Fellow monks,

Is there a trick to get Net::POP3 to check multiple mailboxes on a server for the purpose of determining the number of pending messages? I've tried the following code and it works fine for the first user, but subsequent users come up with no mail, when I know there is mail there. Setting it up with a single user login/pw it works like a champ, but I'd like a way to just do a simple check every now and again to see if it's piling up.

The reason I'm doing this is that I've got a user on the system who is complaining of e-mail retrieval being slow and I want something to physically show them why it is so slow and going to get worse if they don't clean out their mailbox. Fortunately it's only affecting the one user, not everyone.

use strict; use Net::POP3; $|++; my %user = ( a => 1 , b => 2, c => 3); my $host = "host.net"; my $pop = Net::POP3->new($host); for my $key ( keys %user){ print "Working on $key...\n"; my $msg = $pop->login( $key, $user{$key} ); print "$key: $msg\n"; $pop->quit; }

I've tried using a sleep(15) after the $pop->quit so that the server had time to reset, but that didn't work either.

Can anybody shed light on why this behaves the way it does, or is that the expected behavior?

Revolution. Today, 3 O'Clock. Meet behind the monkey bars.

I would love to change the world, but they won't give me the source code

Replies are listed 'Best First'.
Re: Checking muliptle mailboxes on same server with Net::POP3
by Joost (Canon) on Apr 13, 2007 at 00:15 UTC
    Have you tried creating a new Net::POP3 object for each user?

    i.e.

    use strict; use Net::POP3; $|++; my %user = ( a => 1 , b => 2, c => 3); my $host = "host.net"; for my $key ( keys %user){ my $pop = Net::POP3->new($host); print "Working on $key...\n"; my $msg = $pop->login( $key, $user{$key} ); print "$key: $msg\n"; $pop->quit; }
    I haven't used Net::POP3 at all but it might be worth a try.
      No I haven't tried that. That never even occurred to me. Thanks!

      That may be the exact problem as like I had said, I can check for a single user, hard coded in the $pop->login portion but it was choking on different users.

      Update: That did the trick! I didn't see anything in the docs about that, but perhaps I missed it.

      Revolution. Today, 3 O'Clock. Meet behind the monkey bars.

      I would love to change the world, but they won't give me the source code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://609793]
Approved by Joost
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2019-05-20 03:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (123 votes). Check out past polls.

    Notices?