NAME

Mail::DKIM2::Split - Bcc-safe recipient grouping before DKIM2 signing

SYNOPSIS

use Mail::DKIM2::Split qw(plan_copies);

my $copies = plan_copies($message_bytes, ['<a@x>', '<b@y>', '<bcc@z>']);
# -> [ { rcpts => ['<a@x>','<b@y>'] },   # disclosed (in To:/Cc:), one copy
#      { rcpts => ['<bcc@z>'] } ]         # Bcc, its own copy

DESCRIPTION

A DKIM2-Signature records the hop's RCPT TO in rt=. Signing one copy of a message to every recipient would put the Bcc recipients in every copy's rt=, where every other recipient can read them. The message has to be split before signing: recipients named in To: or Cc: can share one copy, and each undisclosed recipient gets a copy of their own. This is the grouping logic, with no network in it; the LMTP daemon in the dkim2.com deployment uses it to fan a submission out into per-copy re-injections.

FUNCTIONS

plan_copies($message_bytes, \@envelope_rcpts)

An arrayref of { rcpts => [...] }: one entry for all the disclosed recipients, then one per undisclosed recipient, preserving the envelope strings as given. A recipient not found in To:/Cc: is undisclosed, so a message with neither header yields one copy per recipient.

disclosed_addresses($message_bytes)

A hashref of lowercased addresses named in To: and Cc:.

AUTHOR

Bron Gondwana <brong@fastmailteam.com>

COPYRIGHT AND LICENSE

Copyright (c) 2025-2026 Fastmail Pty Ltd. This is free software; you can redistribute it and/or modify it under the same terms as Perl itself.