API / Minn\Mail / Dkim

Dkim final class

Minn\Mail\Dkim · public/minn/src/Minn/Mail/Dkim.php · 110 lines

DKIM signatures (RFC 6376) as the reference's mailer writes them: rsa-sha256, relaxed header and simple body canonicalization, the standard headers signed in the order they appear (plus any extra ones the caller names), an optional identity, the signed headers copied into z= when asked, and the signature folded in 73-character pieces.

Uses 1

Constants and properties

privateSIGNED = array ( 0 => 'from', 1 => 'to', 2 => 'cc', 3 => 'date', 4 => 'subject', 5 => 'reply-to', 6 => 'message-id', 7 => 'content-type', 8 => 'mime-version', 9 => 'x-mailer', )
privatebool $copyHeaders
privatereadonly string $domain

Promoted from the constructor.

privatereadonly string $selector

Promoted from the constructor.

privatereadonly string $key

Promoted from the constructor.

privatereadonly string $passphrase

Promoted from the constructor.

privatereadonly string $identity

Promoted from the constructor.

Public

new__construct(string $domain, string $selector, string $key, string $passphrase, string $identity)#
$keystringthe private key (PEM text)
methodcopyingHeaders(): self#

The same signer, copying the signed headers into z= as well.

staticquotedPrintable(string $text): string#

Text with everything outside the DKIM-safe printable set written as =XX.

staticheaders(string $text): string#

Relaxed header canonicalization: unfolded, names lower-cased, runs of space collapsed, values trimmed.

staticbody(string $body): string#

Simple body canonicalization: CRLF line endings and exactly one at the end.

methodsign(string $text): ?string#

The base64 RSA-SHA256 signature of the text, or null when the key cannot be read.

methodsignatureHeader(string $headerBlock, string $subject, string $body, int $time, array $extra, string $eol): ?string#

The DKIM-Signature header for a message, signed at $time.

$extralist<string>lower-case names of further headers to sign

Internals 1

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatesignedHeaders(string $headerBlock, array $extra): array#
$extralist<string>
@return array{0: list<string>, 1: list<string>, 2: list<string>} names, header lines and z= copies