Wise monks,
please help this lowly Perl hacker with an annoying problem.
I am working on a email script and ran into problems.
I have hacked together the following script to test if I can access a pop3 server.
When run locally on my M$ XP box under cygwin it works fine, when I upload it to my hosted webserver it fails and it is beyond me as to why.
The error I get is:
Can't call method "login" on an undefined value at /home/xxx/xxx/TestPopMail.pl line 22.
Any suggestions, the small script is listed below.
#!/usr/bin/perl -wT
use CGI::Carp qw( fatalsToBrowser );
print "Content-type: text/html\n\n";
print "<html><head><title>Test Page</title></head><body>";
$| = 1;
use warnings;
use strict;
eval( "use Net::POP3;" );
die "Module Configuration Error: $@" if $@;
my $time = scalar localtime;
my $pop3 = "xxx.xxx.xxx";
my $login = "xxx\@xxx.xxx";
my $pass = "xxxxxxxx";
my $pop = Net::POP3->new($pop3);
#my $smtp = Net::SMTP->new($ssmtp);
$res = $pop->login($login, $pass);
if ($res eq "undef"){
print "Couldn't connect $!\n";
} else {
print "On $time e-mail status inbox: $res post \n";
}
my $i =0;
print("Deleting $res mails ...\n");
for($i = 0; $i<$res; $i++) {
# $pop->delete($i);
}
$pop->quit();
print "</html></body>";
_update/idea_
Looking at this I am wondering if I am not getting a connection to the pop3 server, and that in turn is causing the error in the login call?
Kia Kaha, Kia Toa, Kia Manawanui!
Be Strong, Be Brave, Be perservering!