logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Re: Newbie: Perl script to check pop3: msg#00282

Subject: Re: Newbie: Perl script to check pop3
Hawk wrote:
Hi,

I want to write a script that will test a pop3 server to see if it is responding. Here's my attempt:

#!/usr/bin/perl

use Net::POP3;

$pop3host = 'localhost';

$pop = Net::POP3->new('$pop3host');
$pop = Net::POP3->new('$pop3host', Timeout => 30);

$pop = user ( 'test' );

if ( $pop = '1' ) {
     print "POP3 is still responding\.\n";
  } else {
         print "POP3 is down\.\n";
    }

This will return the number of emails available in addition to checking
the server:

use strict;
use Net::POP3;

my $server = 'mail.domain.com';         # your POP3 server
my $user = 'user';                      # your username
my $pass = 'passwd';                    # your password

my $srv = Net::POP3->new($server);
$srv->login($user, $pass) or die "login: $!";
my $msg = $srv->list() or die "list: $!";
print scalar (keys %$msg), " message(s)\n";

__END__

--
  ,-/-  __      _  _         $Bill Luebkert   ICQ=162126130
 (_/   /  )    // //       DBE Collectibles   Mailto:dbe@xxxxxxxxx
  / ) /--<  o // //      http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic http://www.todbe.com/

_______________________________________________
ActivePerl mailing list
ActivePerl@xxxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



<Prev in Thread] Current Thread [Next in Thread>