public function PHPMailer::DKIM_Sign

5.x PHPMailer.php public PHPMailer::DKIM_Sign($signHeader)

Generate a DKIM signature.

Parameters

string $signHeader:

Return value

string The DKIM signature value

Throws

Exception

1 call to PHPMailer::DKIM_Sign()
PHPMailer::DKIM_Add in inc/PHPMailer/src/PHPMailer.php
Create the DKIM header and body in a new message header.

File

inc/PHPMailer/src/PHPMailer.php, line 4313

Class

PHPMailer
PHPMailer - PHP email creation and transport class.

Namespace

PHPMailer\PHPMailer

Code

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')) {
    openssl_pkey_free($privKey);

    return base64_encode($signature);
  }
  openssl_pkey_free($privKey);

  return '';
}