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