Commit | Line | Data |
---|---|---|
6a11a9e6 JH |
1 | use Mail::DKIM::Signer; |
2 | use Mail::DKIM::TextWrap; #recommended | |
3 | use Getopt::Long; | |
4 | ||
abe1010c | 5 | # default option values |
6a11a9e6 | 6 | my $method = "simple/simple"; |
abe1010c JH |
7 | my $selector = "sel"; |
8 | my $keyfile = "aux-fixed/dkim/dkim.private"; | |
6a11a9e6 JH |
9 | |
10 | GetOptions( | |
11 | "method=s" => \$method, | |
abe1010c JH |
12 | "selector=s" => \$selector, |
13 | "keyfile=s" => \$keyfile, | |
6a11a9e6 JH |
14 | ); |
15 | ||
16 | # create a signer object | |
17 | my $dkim = Mail::DKIM::Signer->new( | |
18 | Algorithm => "rsa-sha1", | |
19 | Method => $method, | |
20 | Domain => "test.ex", | |
abe1010c JH |
21 | Selector => $selector, |
22 | KeyFile => $keyfile, | |
6a11a9e6 JH |
23 | ); |
24 | ||
25 | # read an email and pass it into the signer, one line at a time | |
26 | while (<STDIN>) | |
27 | { | |
28 | # remove local line terminators | |
29 | chomp; | |
30 | s/\015$//; | |
31 | ||
32 | # use SMTP line terminators | |
33 | $dkim->PRINT("$_\015\012"); | |
34 | } | |
35 | $dkim->CLOSE; | |
36 | ||
37 | # what is the signature result? | |
38 | my $signature = $dkim->signature; | |
39 | print $signature->as_string; | |
40 | print "\n"; | |
41 | ||
42 | #print $dkim->headers; | |
43 | #print "\n"; |