class DkimSigner implements Signer

Signs email messages using DKIM (DomainKeys Identified Mail).

Constants

private DefaultSignHeaders

private DkimSignature

Methods

__construct(string $domain, string $selector, string $privateKey, string|null $passPhrase = null, array $signHeaders = self::DefaultSignHeaders)

No description

string
generateSignedMessage(Message $message)

Returns the signed message as a string with the DKIM-Signature header prepended.

string
getSignature(Message $message, string $header, string $body)

Builds the DKIM-Signature header value.

string
computeSignature(string $rawHeader, string $signature)

Canonicalizes the selected headers, signs them, and returns the complete DKIM-Signature header string.

string
sign(string $value)

Signs the value with the RSA private key and returns the base64-encoded signature.

string
computeBodyHash(string $body)

Computes the base64-encoded SHA-256 hash of the canonicalized body.

string
normalizeNewLines(string $s)

Normalizes line endings to CRLF and ensures the body ends with a single CRLF.

array
getSignedHeaders(Message $message)

No description

int
getTime()

No description

Details

at line 33
__construct(string $domain, string $selector, string $privateKey, string|null $passPhrase = null, array $signHeaders = self::DefaultSignHeaders)

No description

Parameters

string $domain
string $selector
string $privateKey
string|null $passPhrase
array $signHeaders

Exceptions

NotSupportedException

at line 53
string generateSignedMessage(Message $message)

Returns the signed message as a string with the DKIM-Signature header prepended.

Parameters

Message $message

Return Value

string

Exceptions

SignException

at line 70
protected string getSignature(Message $message, string $header, string $body)

Builds the DKIM-Signature header value.

Parameters

Message $message
string $header
string $body

Return Value

string

at line 98
protected string computeSignature(string $rawHeader, string $signature)

Canonicalizes the selected headers, signs them, and returns the complete DKIM-Signature header string.

Parameters

string $rawHeader
string $signature

Return Value

string

at line 127
protected string sign(string $value)

Signs the value with the RSA private key and returns the base64-encoded signature.

Parameters

string $value

Return Value

string

Exceptions

SignException

at line 145
protected string computeBodyHash(string $body)

Computes the base64-encoded SHA-256 hash of the canonicalized body.

Parameters

string $body

Return Value

string

at line 159
protected string normalizeNewLines(string $s)

Normalizes line endings to CRLF and ensures the body ends with a single CRLF.

Parameters

string $s

Return Value

string

at line 168
protected array getSignedHeaders(Message $message)

No description

Parameters

Message $message

Return Value

array

at line 174
protected int getTime()

No description

Return Value

int