Small bug on PERL script
$5-10 USD
Teslim sırasında ödenir
Having a bug error with a perl script. Need this fixed so our program works again to imap into gmail and compile a list of all email addresses. I will provide complete scripts once you accept the project. Getting following error when I run it via command line:
[root@web1 /u/home/o/onli17/public_html/gmailimap]# ./[url removed, login to view]
Can't call method "login" on an undefined value at ./[url removed, login to view] line 84.
(please see further description)
## Deliverables
line 84 is the "die" line in the following section of the script: [url removed, login to view]
}
sub extractAddresses {
for(my $i = 0; $i < @imap_usernames; $i++) {
my $imap = Net::IMAP::Simple::SSL->new('[url removed, login to view]');
die('Error logging in with '.$imap_usernames[$i]) if(!$imap->login($imap_usernames[$i] => $imap_passwords[$i]));
my $msgnum = $imap->select($imap_foldername);
print "[INFO] Logged in to SMTP with username ".$imap_usernames[$i].", extracting addresses...\n";
# extract names and addresses from mails
my $maxDate = str2time(getLastCheck($imap_usernames[$i]));
my $queryDate = time2str("%d", $maxDate)."-".$months[int(time2str("%L", $maxDate)) - 1]."-".time2str("%Y", $maxDate)
;
my @ids = imapsearch($imap, "SENTSINCE $queryDate");
$msgnum = @ids;
my $count = 0;
foreach my $i (@ids) {
$count++;
printf("\r%d / %d (%.2f%)", $count, $msgnum, ($count / $msgnum * 100)) if($print_progress);
my $imapRes = $imap->top($i);
if(defined($imapRes)) {
my $email = Email::Simple->new(join '', @{$imapRes});
my @to_adr = Email::Address->parse($email->header('to'));
my @cc_adr = Email::Address->parse($email->header('cc'));
foreach my $adr ((@to_adr, @cc_adr)) {
my $phrase = decode('MIME-Header', $adr->phrase);
utf8::encode($phrase);
my $lcaddress = lc($adr->address);
$lcaddress =~ s/'//g;
if((!defined($all_messages{$lcaddress})) ||
(($phrase ne "") && ($all_messages{$lcaddress} ne $phrase))) {
$all_messages{$lcaddress} = $phrase;
}
}
}
}
print "\n" if(($print_progress) && ($msgnum > 0));
print "[INFO] Done.\n";
$imap->quit;
}
}
Proje NO: #2781380