LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   perl script to report new mail (https://www.linuxquestions.org/questions/programming-9/perl-script-to-report-new-mail-339332/)

nibbler 07-02-2005 08:37 AM

perl script to report new mail
 
this is a perl script run by cynapses_karamba. It is supposed to get new mail count from gmail. The problem is that it always dies at "Couldn't log on to server". I've enabled POP3 on gmail. I haven't really programmed in perl, so it's hard for me to debug. Can someone tell what is wrong:
Code:

#!/usr/bin/perl
use Net::POP3;

my $ServerName = "pop.gmail.com";
# If your username contains a @ character you
# must replace it with \@
my $UserName = "myusrname\@gmail.com";
my $Password = "my_pass";
my $pop3 = Net::POP3->new($ServerName,Timeout => 5);
die "Couldn't log on to server" unless $pop3;

my $Num_Messages = $pop3->login($UserName, $Password) + 0;
if ( $Num_Messages == 1 ){
  print $Num_Messages ." new\n";
}
elsif ( $Num_Messages > 1 ){
    print $Num_Messages ." new\n";
}
else{
    print "0 new\n";
}

$pop3->quit();

For those of you who have cynapses_karamba, have you managed to enable network ingoing/outgoing graph? I haven't :(

david_ross 07-02-2005 09:13 AM

I think you need to use ssl with gmail. I'd either set up an stunnel wrapper for that script or us this cpan module instead of Net::POP3:
http://search.cpan.org/~sdowd/Mail-P.../POP3Client.pm


All times are GMT -5. The time now is 10:57 AM.