Keep options ordered alphabetical
[exim.git] / test / aux-fixed / dkim / sign.pl
CommitLineData
6a11a9e6
JH
1use Mail::DKIM::Signer;
2use Mail::DKIM::TextWrap; #recommended
3use Getopt::Long;
4
abe1010c 5# default option values
6a11a9e6 6my $method = "simple/simple";
abe1010c
JH
7my $selector = "sel";
8my $keyfile = "aux-fixed/dkim/dkim.private";
6a11a9e6
JH
9
10GetOptions(
11 "method=s" => \$method,
abe1010c
JH
12 "selector=s" => \$selector,
13 "keyfile=s" => \$keyfile,
6a11a9e6
JH
14);
15
16# create a signer object
17my $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
26while (<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?
38my $signature = $dkim->signature;
39print $signature->as_string;
40print "\n";
41
42#print $dkim->headers;
43#print "\n";