Skip to content

Commit

Permalink
Adding passphrase support (#9)
Browse files Browse the repository at this point in the history
* Added passphrase for parameter for private key

* Updated README.md
  • Loading branch information
rdanklof authored and vitalybaev committed Jan 17, 2019
1 parent b1b7b40 commit 1392fa3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Vitalybaev\LaravelDkim\DkimMailServiceProvider::class,
'dkim_private_key' => env('MAIL_DKIM_PRIVATE_KEY'), // path to private key, required
'dkim_identity' => env('MAIL_DKIM_IDENTITY'), // identity (optional)
'dkim_algo' => env('MAIL_DKIM_ALGO'), // sign algorithm (defaults to rsa-sha256)
'dkim_passphrase' => env('MAIL_DKIM_PASSPHRASE'), // private key passphrase (optional)
```

## License
Expand Down
2 changes: 1 addition & 1 deletion src/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected function createMessage()
if (in_array(strtolower(config('mail.driver')), ['smtp', 'sendmail', 'log'])) {
if (config('mail.dkim_private_key') && file_exists(config('mail.dkim_private_key'))) {
if (config('mail.dkim_selector') && config('mail.dkim_domain')) {
$message->attachDkim(config('mail.dkim_selector'), config('mail.dkim_domain'), file_get_contents(config('mail.dkim_private_key')));
$message->attachDkim(config('mail.dkim_selector'), config('mail.dkim_domain'), file_get_contents(config('mail.dkim_private_key')), config('mail.dkim_passphrase'));
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ class Message extends \Illuminate\Mail\Message
* @param $selector
* @param $domain
* @param $privateKey
* @param $passphrase
*
* @return $this
*/
public function attachDkim($selector, $domain, $privateKey)
public function attachDkim($selector, $domain, $privateKey, $passphrase = '')
{
$signer = new Swift_Signers_DKIMSigner($privateKey, $domain, $selector);
$signer = new Swift_Signers_DKIMSigner($privateKey, $domain, $selector, $passphrase);
$signer->setHashAlgorithm(config('mail.dkim_algo', 'rsa-sha256'));
if (config('mail.dkim_identity')) {
$signer->setSignerIdentity(config('mail.dkim_identity'));
Expand Down

0 comments on commit 1392fa3

Please sign in to comment.