ASNMTAP
view release on metacpan or search on metacpan
lib/ASNMTAP/Asnmtap/Plugins/Mail.pm view on Meta::CPAN
$$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => "Cannot connect/login to POP3 server: $self->{_POP3}->{pop3}" }, $TYPE{APPEND} );
return ( $ERRORS{UNKNOWN} );
}
} else {
$$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'NO EMAIL CLIENT SPECIFIED !!!' }, $TYPE{APPEND} );
return ( $ERRORS{UNKNOWN} );
}
if ( defined $numberOfMails ) {
my $returnCode = $ERRORS{DEPENDENT};
$self->{defaultArguments}->{numberOfMatches} = 0;
if ( $numberOfMails ) {
use MIME::Parser;
my $parser = new MIME::Parser;
$parser->output_to_core(1);
$parser->decode_bodies(1);
use constant HEADER => '<?xml version="1.0" encoding="UTF-8"?>';
use constant SYSTEM => 'dtd/FingerprintEmail-1.0.dtd';
use constant FOOTER => '</FingerprintEmail>';
my $fingerprintXML = HEADER .'<!DOCTYPE FingerprintEmail SYSTEM "'. SYSTEM .'"><FingerprintEmail>';
my $debug = $$asnmtapInherited->getOptionsValue ('debug');
my $label;
for( my $msgnum = 1; $msgnum <= $numberOfMails; $msgnum++ ) {
print "\n", ref ($self), "::receiving_fingerprint_mails(): message number $msgnum\n" if ( $debug );
my ($fromNotFound, $toNotFound, $subjectNotFound, $fingerprintFound) = (1, 1, 1, 3);
my ($messageNotFound, $brandingNotFound, $timestampNotFound, $statusNotFound, $xmlNotFound) = (0, 0, 0, 0, 0);
if ( $parms{checkFingerprint} ) {
$statusNotFound = 1;
if ( $self->{_mailType} ) {
($xmlNotFound, $fingerprintFound) = (1, $fingerprintFound + 2);
} else {
($messageNotFound, $brandingNotFound, $timestampNotFound, $fingerprintFound) = (1, 1, 1, $fingerprintFound + 4);
}
}
$self->{defaultArguments}->{result} = '';
my $msgbuffer;
if ( defined $self->{_IMAP4}->{imap4} ) {
$msgbuffer = $email->top ( $msgnum );
} elsif ( defined $self->{_POP3}->{pop3} ) {
$msgbuffer = $email->Head ( $msgnum );
}
my $entity = $parser->parse_data( $msgbuffer );
my $head = $entity->head;
$head->unfold;
if ( $debug >= 2 ) {
print ref ($self), "::receiving_fingerprint_mails(): Header\n", $head->stringify, "\n\n";
print ref ($self), "::receiving_fingerprint_mails(): MIME-Version: ", $head->get ('MIME-Version'), "\n";
print ref ($self), "::receiving_fingerprint_mails(): MIME-Type: ", $head->mime_type, "\n";
print ref ($self), "::receiving_fingerprint_mails(): MIME-Encoding: ", $head->mime_encoding, "\n";
print ref ($self), "::receiving_fingerprint_mails(): Content-Type Charset: ", $head->mime_attr ('content-type.charset'), "\n"if ( $head->mime_attr('content-type.charset') );
print ref ($self), "::receiving_fingerprint_mails(): Content-Type Name: ", $head->mime_attr('content-type.name'), "\n" if ( $head->mime_attr('content-type.name') );
print ref ($self), "::receiving_fingerprint_mails(): Multipart Boundary: ", $head->multipart_boundary, "\n" if ( $head->multipart_boundary );
}
print "\n", ref ($self), "::receiving_fingerprint_mails(): HEAD\n" if ($debug);
foreach my $msgline ( split (/[\n\r]/, $head->stringify) ) {
next unless ( $msgline );
if ( $fromNotFound ) {
if ($msgline =~ /^$self->{_text}->{from}/) {
print "From .... : $msgline\n" if ($debug);
$fromNotFound = ( $msgline !~ /^$self->{_text}->{from}\s+$self->{_mail}->{from}/ ? 1 : 0 );
my $label = $fromNotFound ? ' (?)' : '(match)';
print " $label : $self->{_text}->{from} $self->{_mail}->{from}\n" if ($debug);
unless ( $fromNotFound ) { $fingerprintFound--; next; }
}
}
if ( $toNotFound ) {
if ($msgline =~ /^$self->{_text}->{to}/) {
print "To ...... : $msgline\n" if ($debug);
$toNotFound = ( $msgline !~ /^$self->{_text}->{to}\s+$self->{_mail}->{to}/ ? 1 : 0 );
my $label = $toNotFound ? ' (?)' : '(match)';
print " $label : $self->{_text}->{to} $self->{_mail}->{to}\n" if ($debug);
unless ( $toNotFound ) { $fingerprintFound--; next; }
}
}
if ( $subjectNotFound ) {
if ($msgline =~ /^$self->{_text}->{subject}/) {
print "Subject . : $msgline\n" if ($debug);
$subjectNotFound = ( $msgline !~ /^$self->{_text}->{subject}\s+$self->{_subject_}/ ? 1 : 0 );
my $label = $subjectNotFound ? ' (?)' : '(match)';
print " $label : $self->{_text}->{subject} $self->{_subject_}\n" if ($debug);
unless ( $subjectNotFound ) { $fingerprintFound--; next; }
}
}
}
unless ( $fromNotFound or $toNotFound or $subjectNotFound ) {
print "\n", ref ($self), "::receiving_fingerprint_mails(): BODY\n" if ($debug);
if ( defined $self->{_IMAP4}->{imap4} ) {
use Email::Simple;
my $mail = Email::Simple->new( join ( '', @{ $email->get ( $msgnum ) } ) );
$msgbuffer = $mail->body;
} elsif ( defined $self->{_POP3}->{pop3} ) {
$msgbuffer = $email->Body ( $msgnum );
}
use MIME::Decoder;
unless ( supported MIME::Decoder $head->mime_encoding ) {
print "MIME .... : '". $head->mime_encoding ."' encoding is not supported!\n" if ($debug );
$returnCode = $ERRORS{UNKNOWN};
$$asnmtapInherited->pluginValues ( { stateValue => $returnCode, error => "MIME-Encoding: '". $head->mime_encoding ."' is not supported!" }, $TYPE{APPEND} );
next;
}
# if ( $head->mime_encoding eq 'quoted-printable' or $head->mime_encoding eq '7bit' or $head->mime_encoding eq '8bit' ) {
( run in 2.133 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )