This script basically connects to all 3 of my e-mail accounts, downloads the messages, and then runs them through a filter before delivering them to the local inbox. The filter works fine so I will not post it, and this script works for 2 accounts, so I am not sure where the problem is, the accoutn that does nto work in the script works fine in thunderbird witht he same settings.
Script (I have removed my passwords):
Code:
#!/usr/bin/perl
use strict;
use Mysql;
use Mail::POP3Client;
sub DoAccount($);
my @Accounts;
$Accounts[0] = {'Name' => 'exodist7@gmail',
'Server' => 'pop.gmail.com',
'Username' => 'exodist7',
'Password' => '********',
'SSL' => '1',
'PORT' => '995'};
$Accounts[1] = {'Name' => 'exodist@yifan.net',
'Server' => 'mail.yifan.net',
'Username' => 'exodist',
'Password' => '*********'};
$Accounts[2] = {'Name' => 'cgranum@garymckelvey.com',
'Server' => 'mail.garymckelvey.com',
'Username' => 'cgranum',
'Password' => '********'};
MAIN:
{
foreach my $I (@Accounts)
{
print("Account: $I->{'Name'}\n");
DoAccount($I);
}
}
sub DoAccount($)
{
my ($AN) = @_;
my $CreateString;
my $Message;
my $Sender;
my $Recipient;
my $Temp;
my $TMPFile;
$CreateString = "\tUSER => '$AN->{'Username'}',
PASSWORD => '$AN->{'Password'}',
HOST => '$AN->{'Server'}'";
$CreateString .= ",\n\tUSESSL => 'true'" if ($AN->{'SSL'});
$CreateString .= ",\n\tPORT => '$AN->{'PORT'}'" if ($AN->{'PORT'});
my $pop = new Mail::POP3Client(eval($CreateString));
print("Logging in....");
if (!($pop->Login()))
{
print("Could not connect to account: $AN->{'Name'}: $!\n");
return 1;
}
print("Logged in!\t");
print("Total Messages: " . $pop->Count() . "\n");
foreach my $I (1 .. $pop->Count())
{
$Message = $pop->HeadAndBody($I);
foreach my $Line (split(/\n/, $Message))
{
if (($Line =~ m/^From:.*$/ig) && (!($Sender)))
{
$Temp = $&;
print("Temp: $Temp\n");
if ("$Temp" =~ m/[A-Za-z0-9-]+\@[A-Za-z0-9-]+\.[A-Za-z0-9-]+/ig)
{
$Sender = $&;
}
}
last if ($Sender);
}
if (!($Sender))
{
print("Error finding sender!\n");
next;
}
do
{
$TMPFile = "/tmp/MAILSYSTEM-" . rand(1000000000) . ".eml";
} while (-e $TMPFile);
open(TMP, ">$TMPFile");
print TMP $Message;
close(TMP);
if (system("/server/Mailque/bin/newfilter.pl \"$Sender\" \"exodist\@open-exodus.net\" < $TMPFile"))
{
print("Error sending message!!!\n");
}
else
{
$pop->Delete($I);
}
unlink($TMPFile);
}
}
here is the output:
Code:
Account: exodist7@gmail
Logging in....Logged in! Total Messages: 0
#--------here is the problem-------------
Account: exodist@yifan.net
Use of uninitialized value in pattern match (m//) at /usr/lib/perl5/vendor_perl/5.8.8/Mail/POP3Client.pm line 1075, <GEN1> line 2.
Logging in....Could not connect to account: exodist@yifan.net:
#--------/problem-------------
Account: cgranum@garymckelvey.com
Logging in....Logged in! Total Messages: 0
here is the output (for the one that fails only) when debug is passed tot he new POP3Client object:
Code:
Account: exodist@yifan.net
POP3 <- +OK <21130.1155263808@mail.yifansoft.com>
at ./GetMail.pl line 55
POP3 -> APOP exodist 9bba8c2446b01583cbc25e2fe219c53c
at ./GetMail.pl line 55
POP3 <- -ERR authorization failed
at ./GetMail.pl line 55
POP3 -> NOOP
at ./GetMail.pl line 55
Use of uninitialized value in pattern match (m//) at /usr/lib/perl5/vendor_perl/5.8.8/Mail/POP3Client.pm line 1075, <GEN1> line 2.
Logging in....Could not connect to account: exodist@yifan.net: