Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^4: Filehandle with DKIM::Verifier

by nifu (Novice)
on Oct 16, 2017 at 08:18 UTC ( [id://1201429]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Filehandle with DKIM::Verifier
in thread Filehandle with DKIM::Verifier

I use this to open the file and parse it with the module Email::Simple;.

This is the code from my "email parse script". I need to extend this script with a DKIM check.

#! /usr/bin/perl use strict; use warnings; use Email::Simple; use DBI; use File::Copy; use Date::Parse; use DateTime; use Path::Tiny qw(path); [..] open (MESSAGE, "< $ARGV[0]") || die "Couldn't open email $ARGV[0]\n"; undef $/; $raw_email = <>; close MESSAGE; my $mail = Email::Simple->new($raw_email); my $from_header = $mail->header("From"); my $to_header = $mail->header("To"); my $date_header = $mail->header("Date"); my $aol_header = $mail->header("Authentication-Results"); [...]
$ARGV is the filename form perl script.pl filename and $raw_email contains the text file.

Replies are listed 'Best First'.
Re^5: Filehandle with DKIM::Verifier
by hippo (Bishop) on Oct 16, 2017 at 10:23 UTC
    This is the code from my "email parse script"

    So that section is not relevant to your test script. If we omit it we can end up with a working version such as:

    use strict; use warnings; use Test::More; use Mail::DKIM::Verifier; my @good = qw/good1.txt good2.txt/; my @bad = qw/bad1.txt bad2.txt/; plan tests => @good + @bad; for my $goodfile (@good) { my $dkim = Mail::DKIM::Verifier->new(); open (my $gfh, '<', $goodfile) or die "Error opening $goodfile: $! +"; $dkim->load ($gfh); is ($dkim->result_detail, 'pass', $goodfile); close $gfh; } for my $badfile (@bad) { my $dkim = Mail::DKIM::Verifier->new(); open (my $bfh, '<', $badfile) or die "Error opening $badfile: $!"; $dkim->load ($bfh); isnt ($dkim->result, 'pass', $badfile); close $bfh; }

    Obviously you can change the filenames in the @good and @bad arrays until you have what you want. This script works fine for me testing on good and bad data.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1201429]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-03-29 13:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found