App-SpamcupNG
view release on metacpan or search on metacpan
lib/App/SpamcupNG.pm view on Meta::CPAN
if ( @{$warns_ref} ) {
foreach my $warning ( @{$warns_ref} ) {
$logger->warn( $warning->message() );
}
}
else {
$logger->info('No warnings found in response');
}
}
if ( my $errors_ref = find_errors($response_ref) ) {
foreach my $error ( @{$errors_ref} ) {
if ( $error->is_fatal() ) {
$logger->fatal( $error->message() );
# must stop processing the HTML for this report and move to next
return 0;
}
else {
$logger->error( $error->message() );
}
}
}
# parsing the SPAM
my $_cancel = 0;
my $base_uri = $ua->base();
unless ($base_uri) {
$logger->die(
'No base URI found. Internal error? Please report this error by registering an issue on Github'
);
}
if ( $logger->is_debug ) {
$logger->debug("Base URI is $base_uri");
}
my $best_ref = find_best_contacts($response_ref);
$summary->set_contacts($best_ref);
if ( $logger->is_info ) {
if ( @{$best_ref} ) {
my $best_as_text = join( ', ', @$best_ref );
$logger->info("Best contacts for SPAM reporting: $best_as_text");
}
}
my $form = _report_form( $response_ref, $base_uri );
$logger->die(
'Could not find the HTML form to report the SPAM! May be a temporary Spamcop.net error, try again later! Quitting...'
) unless ( defined($form) );
my $spam_header_info = find_header_info($response_ref);
$summary->set_mailer( $spam_header_info->{mailer} );
$summary->set_content_type( $spam_header_info->{content_type} );
$summary->set_charset( $spam_header_info->{charset} );
if ( $logger->is_info ) {
$logger->info( 'X-Mailer: ' . $summary->to_text('mailer') );
$logger->info( 'Content-Type: ' . $summary->to_text('content_type') );
my $spam_header_ref = find_spam_header($response_ref);
if ($spam_header_ref) {
my $as_string = join( "\n", @$spam_header_ref );
$logger->info("Head of the SPAM follows:\n$as_string");
}
else {
$logger->warn('No SPAM header found');
}
# how many recipients for reports
my $max = $form->value("max");
my $willsend;
my $wontsend;
# iterate targets
for ( my $i = 1 ; $i <= $max ; $i++ ) {
my $send = $form->value("send$i");
my $type = $form->value("type$i");
my $master = $form->value("master$i");
my $info = $form->value("info$i");
# convert %2E -style stuff back to text, if any
if ( $info =~ /%([A-Fa-f\d]{2})/g ) {
$info =~ s/%([A-Fa-f\d]{2})/chr hex $1/eg;
}
if (
$send
and ( ( $send eq 'on' )
or ( $type =~ /^mole/ and $send == 1 ) )
)
{
$willsend .= "$master ($info)\n";
}
else {
$wontsend .= "$master ($info)\n";
}
}
my $message =
'Would send the report to the following addresses (reason in parenthesis): ';
if ($willsend) {
$message .= $willsend;
}
else {
$message .= '--none--';
}
$logger->info($message);
$message = 'Following addresses would not be used: ';
if ($wontsend) {
$message .= $wontsend;
( run in 1.583 second using v1.01-cache-2.11-cpan-98e64b0badf )