Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#2 Get error in normal operation

open
nobody
None
5
2003-01-21
2003-01-21
Anonymous
No

When using the module to validate email addresses
from our client and contact database I get an error:

Usage> nack($failed_ack_host)
at /usr/lib/perl5/site_perl/5.6.1/Mail/CheckUser.pm line
261

Here is the programme I was using at the time:

#!/usr/bin/perl

# Write email list upload form to browser.

use Time::Local;
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);

use Mail::CheckUser qw(:constants check_email
last_check);

use Text::ParseWords;
use Text::CSV_XS;

# Turn off internal caching of output buffer
$| = 1;

$cgidir = ".";
$email = "";
$templates='/home/emailres/www/dnf';

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isd
st) = localtime(time);
$year += 1900;

$function = param('function');

&upload;
exit;

##############################################
##########################

sub printerr {
&printheader;
print "$errormsg";
&printfooter;
exit;

}

sub printheader {
print header();
open
(TEMPLATE,"<$templates/header.html");
@output=<TEMPLATE>;
close (TEMPLATE);
print "@output";
}
sub printheader1 {
open
(TEMPLATE,"<$templates/header.html");
@output=<TEMPLATE>;
close (TEMPLATE);
print "@output";
}
sub printfooter {
open (TEMPLATE,"<$templates/footer.html");
@output=<TEMPLATE>;
close (TEMPLATE);
print "@output";
}

sub upload {

print_form() unless (param('upload'));
print_results() if (param('upload'));
print end_html;
}

sub print_form {
print header,
start_html(-title=>'Upload a file to
clean',
-
bgcolor=>'#ffffcc'),
table({-border=>'0', -width=>'500' -
cellspacing=>'2', Cellpadding=>'2'},
#Tr(td([img
({src=>'http://donotfaxlist.com/images/20021128-
logo.gif', align=>center})])),
Tr(td
([start_multipart_form()])),
Tr(td(p('Using the file
browser box below, select the file you wish to
validate.'))),
Tr(td(filefield(-
name=>'upload',-size=>50), hidden(-name=>'function', -
value=>'upload'))),
Tr(td([submit(-
label=>'Upload File')])) ),
end_form,
end_html;
return;
}

sub print_results {
my $length;
my $file = param('upload');
my $removes_cnt = 0;

my $rej_bs = 0;
my $rej_ud = 0;
my $rej_dt = 0;
my $rej_uu = 0;
my $rej_us = 0;
my $rej_mf = 0;
my $ln_count = 0;

$Mail::CheckUser::Skip_SMTP_Checks = 0;

my $csv = Text::CSV_XS->new;

print header,
start_html(-title=>'This is the
uploaded file',
-
bgcolor=>'#ffffcc'),
table({-border=>'0', -width=>'500' -
cellspacing=>'2', Cellpadding=>'2'},
Tr(td([h2('Here is your
cleaned list')])),
Tr(td(p('Cut and paste
this list into notepad or similar editor and save it on your
own hard drive. A message will appear at the end of the
list including a count of lines removed.')))),
br,br,br;
while (<$file>) {

#s/\\//g;
#my @in_line =
&parse_line(",", 0, $_);

if ($csv->parse($_)) {
@in_line =
$csv->fields;
} else {
print "failed
to parse: $_",br;
next;
}

my $email = $in_line
[0];

if(check_email
($email)) {

$ln_count++;

print "OK ",$_,br;
} else {
print
last_check->{code}," ", $_ ,br;

$removes_cnt++;
$rej_bs++ if
last_check()->{code} == CU_BAD_SYNTAX;
$rej_ud++ if
last_check()->{code} == CU_UNKNOWN_DOMAIN;
$rej_dt++ if
last_check()->{code} == CU_DNS_TIMEOUT;
$rej_uu++ if
last_check()->{code} == CU_UNKNOWN_USER;
$rej_us++ if
last_check()->{code} == CU_SMTP_UNREACHABLE;
$rej_mf++ if
last_check()->{code} == CU_MAILBOX_FULL
}

}
print p('Good addresses -
',$ln_count);
print p('addresses removed-
',$removes_cnt);
print p('REASON:');
print 'Bad Syntax -
',$rej_bs,br;
print 'Unknown Domain -
',$rej_ud,br;
print 'DNS timeout -
',$rej_dt,br;
print 'Unknown User -
',$rej_uu,br;
print 'SMTP unreachable -
',$rej_us,br;
print 'Mailbox full - ',$rej_mf;
print end_html;
return;
}

Discussion