From 806b98272f7e89b2611face1656bb472e66702e9 Mon Sep 17 00:00:00 2001 From: Michael Kliewe Date: Sat, 29 Jan 2022 00:05:31 +0100 Subject: [PATCH] GPGMailer::send() should return the encrypted message After sending the email, you might need the encrypted(+signed) message to store it via IMAP into the Sent-folder. --- src/GPGMailer.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/GPGMailer.php b/src/GPGMailer.php index 28aeaec..0ac38d8 100644 --- a/src/GPGMailer.php +++ b/src/GPGMailer.php @@ -206,7 +206,7 @@ public function import(string $gpgKey): string * * @param Message $message The message data * @param string $fingerprint Which public key fingerprint to use - * @return void + * @return Message * * @throws \Crypt_GPG_Exception * @throws \Crypt_GPG_FileException @@ -216,16 +216,20 @@ public function import(string $gpgKey): string public function send(Message $message, string $fingerprint) { if ($this->serverKeyFingerprint) { + $encryptedMessage = $this->encryptAndSign($message, $fingerprint); $this->mailer->send( // Encrypted, signed - $this->encryptAndSign($message, $fingerprint) + $encryptedMessage ); } else { + $encryptedMessage = $this->encrypt($message, $fingerprint); $this->mailer->send( // Encrypted, unsigned - $this->encrypt($message, $fingerprint) + $encryptedMessage ); } + + return $encryptedMessage; } /**