default color: lavender w/red vlinks)
change to: default, lav, whi, gra, ora

Mail-Penguin::Main: Logon

last updated: Sunday, 24-Jan-1999 02:50:18 EST
[an error occurred while processing this directive]   visit to this page
[ write to Jeff ]

####################################################
sub logon_to_pop_server {
    
    $waiting_mail_count = 0;  # initialize
    
	# We'll use the 'black box' POP3.pm to make
        # a new connection with the POP server;
        # $remote[$mx] is found by a -number- we pass
        # to the program on the command line, now
        # stored in the '$mx' variable. That number
        # correlates with our list of servers, @remote.

    $pop3 = Net::POP3->new( $remote[$mx] ); 

	# Sometimes the server's on coffee break :-)
        # The POP3.pm module has a built-in default
        # time-out feature; the default is 120 seconds
        # as "long enough" to see if the server's
        # able and willing to talk to us.  If not,
        # we'll return to our main 'do' loop, where
        # the 'next' instruction is waiting for cases
        # like that.  We'd move on, then, to the next
        # server in our list; if there are no more
        # servers in our list, the program will take
        # a nap and then start all over again.

    if (!defined $pop3)
    {
        warn "  $remote[$mx]: not connecting...\n";
        sleep 2;
        return;
    }

    	# If we achieve a connection, we'll show the
        # user at the console the name of the server
        # we're presently talking to:

    print "  $remote[$mx]: ";
       
	# Then we'll use POP3.pm to identify who we
        # are (as known to this particular server).
        # Again, we'll use the '$mx' variable, holding
        # a value we got from the command line when
        # the program was launched.

    $result = $pop3->user( $user[$mx] );
    if (!$result == 1)
    {
        warn "not accepting user...\n";
        $pop3->quit;
        sleep 2;
        return;
    }

	# Depending on the server's setup, we might
        # already have been informed how many (if any)
        # emails are waiting for us; we won't concern
        # ourselves with that just yet, and will now
        # send the password for this account, using $mx.

    $result = $pop3->pass( $pass[$mx] );
    if (!defined $result)
    {
        warn "not accepting pass...\n";
        $pop3->quit;
        sleep 2;
        return;
    }

    	# Most pop servers send a mail count with their
        # '+OK' response to the password -- but not all
        # do; PowerWeb is one example -- so we'll send
        # the 'popstat' query also, and finally notify
        # the user at the console how many emails are
        # waiting here for us.

    ($waiting_mail_count) = $pop3->popstat;

    print "$waiting_mail_count item";
    unless ($waiting_mail_count == 1) { print "s"; }
    print "\n";
    sleep 2;

} # end of sub logon_to_pop_server

[ back to Main | to sub fetch_waiting_mail_if_any ]