$client = new Mail::POP3Client(USER=>$Name,PASSWORD=>$Pass,HOST=>$Serv);

And why not print $TheState after you get it to find out what's
going on eh?

-Peter

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, March 01, 2001 1:16 PM
> To: [EMAIL PROTECTED]
> Subject: Getting e-mails with Perl
> 
> 
> Hi all, 
> Here is a script using Mail::POP3Client module. I am trying 
> to get my e-mails 
> with Perl.
> The code seems correct, but I can't connect to any host 
> server to get my 
> e-mails. I installed the Mail-POP3Client on my computer. I 
> think it should 
> work, but it doesn't. Please help.
> 
> 
> $Name = 'mylogin';
> $Pass = 'mypassword';
> $Serv = 'mail.domain.com';
> $Subj = 'Subject: Daily logging report';
> 
> use Mail::POP3Client;
> $Client = new Mail::POP3Client($Name, $Pass, $Serv);
> $TheState = $Client->State;
> if($TheState eq 'AUTHORIZATION')
>     { die "Bad user name or password.\n" }
> elsif($TheState eq 'DEAD')
>     { die "Mail server unreachable or unavailable.\n" }
> 
> # Find out how many messages there are
> $NumMsg = $Client->Count;
> 
> #Loop through the messages (starting at 1)
> for($i = 1; $i<=$NumMsg; $i +=1) {
>     $Headers = $Client->Head($i);
>     @HeadList = split(/\n/, $Headers);
>     foreach $Line (@HeadList) {
>         if($Line =~ /^$Subj/) {
>             # Found the message; get the body, then delete
>             $Body = $Client->Body($i);
>             $Client->Delete($i);
>             # Process the report and leave
>             &ProcessReport($Body);
>             last;
>         }
>     }
> }
> # Close the connection so the delete happens
> $Client->Close;
> 
> sub ProcessReport {
>     my($Report) = pop(@_);
>     # Do something here that is processing the report
>     return;
> }
> _______________________________________________
> ActivePerl mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/activeperl
> 
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl

Reply via email to