PHPMailer\PHPMailer

PHPMailer::DKIM_Sign()publicWP 1.0

Generate a DKIM signature.

Method of the class: PHPMailer{}

No Hooks.

Return

String. The DKIM signature value

Usage

$PHPMailer = new PHPMailer();
$PHPMailer->DKIM_Sign( $signHeader );
$signHeader(string) (required)
-

PHPMailer::DKIM_Sign() code WP 6.4.3

public function DKIM_Sign($signHeader)
{
    if (!defined('PKCS7_TEXT')) {
        if ($this->exceptions) {
            throw new Exception($this->lang('extension_missing') . 'openssl');
        }

        return '';
    }
    $privKeyStr = !empty($this->DKIM_private_string) ?
        $this->DKIM_private_string :
        file_get_contents($this->DKIM_private);
    if ('' !== $this->DKIM_passphrase) {
        $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase);
    } else {
        $privKey = openssl_pkey_get_private($privKeyStr);
    }
    if (openssl_sign($signHeader, $signature, $privKey, 'sha256WithRSAEncryption')) {
        if (\PHP_MAJOR_VERSION < 8) {
            openssl_pkey_free($privKey);
        }

        return base64_encode($signature);
    }
    if (\PHP_MAJOR_VERSION < 8) {
        openssl_pkey_free($privKey);
    }

    return '';
}