Reference

Mail::DKIM::SigningFilter(3pm)

signs email with a DKIM signature

NAME

Mail::DKIM::SigningFilter - signs email with a DKIM signature

SYNOPSIS

  use Mail::DKIM::SigningFilter;

  # create a signing filter object
  my $dkim = Mail::DKIM::SigningFilter->new_object(
                  Algorithm => "rsa-sha1",
                  Method => "nowsp",
                  Domain => "example.org",
                  Selector => "selector1",
                  KeyFile => "private.key");
             );

  # read an email from stdin, pass it into the signing filter.
  # the resulting message will be output on STDOUT.
  while (<STDIN>)
  {
      # remove local line terminators
      chomp;
      s/\015$//;

      # use SMTP line terminators
      $dkim->PRINT("$_\015\012");
  }
  $dkim->CLOSE;

DESCRIPTION

The "Signing Filter" is fed an email address and outputs to the specified file handle the same message with a DKIM-Signature prepended.

The steps done are:
1. Parse all headers
2. Modify headers if desired (e.g. remove existing DKIM-Signature?)
3. Determine signature parameters
4. Feed (possibly modified) headers into selected canonicalization/algorithm
5. Receive rest of message and feed it into canonicalization/algorithm
6. Generate signature
7. Write prepended DKIM-Signature header
8. Write (possibly modified in step 2) headers
9. Write body