Skip to content

Commit 2a4918b

Browse files
lamanskySynchro
authored andcommitted
Allow DKIM private key to be provided as a string (PHPMailer#879)
1 parent f92b368 commit 2a4918b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

class.phpmailer.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,13 @@ class PHPMailer
423423
*/
424424
public $DKIM_private = '';
425425

426+
/**
427+
* DKIM private key string.
428+
* If set, takes precedence over `$DKIM_private`.
429+
* @var string
430+
*/
431+
public $DKIM_private_string = '';
432+
426433
/**
427434
* Callback Action function name.
428435
*
@@ -1289,7 +1296,7 @@ public function preSend()
12891296
if (!empty($this->DKIM_domain)
12901297
&& !empty($this->DKIM_private)
12911298
&& !empty($this->DKIM_selector)
1292-
&& file_exists($this->DKIM_private)) {
1299+
&& (!empty($this->DKIM_private_string) || file_exists($this->DKIM_private))) {
12931300
$header_dkim = $this->DKIM_Add(
12941301
$this->MIMEHeader . $this->mailHeader,
12951302
$this->encodeHeader($this->secureHeader($this->Subject)),
@@ -3717,7 +3724,7 @@ public function DKIM_Sign($signHeader)
37173724
}
37183725
return '';
37193726
}
3720-
$privKeyStr = file_get_contents($this->DKIM_private);
3727+
$privKeyStr = !empty($this->DKIM_private_string) ? $this->DKIM_private_string : file_get_contents($this->DKIM_private);
37213728
if ('' != $this->DKIM_passphrase) {
37223729
$privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase);
37233730
} else {

0 commit comments

Comments
 (0)