From 9645c304db5ec2b295e64471e990e08c8ca2b29b Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Sat, 14 Nov 2026 18:56:58 +0000 Subject: [PATCH 1/3] fix(mail): handle rejected verification code recipients fix(mail): handle rejected verification code recipients Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> [skip ci] --- lib/Service/MailService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Service/MailService.php b/lib/Service/MailService.php index b5e331af4c..2888de4576 100644 --- a/lib/Service/MailService.php +++ b/lib/Service/MailService.php @@ -298,7 +298,7 @@ public function sendCodeToSign(string $email, string $name, string $code): void } $message->useTemplate($emailTemplate); try { - $this->mailer->send($message); + $this->sendAndCheck($message); } catch (\Exception $e) { $this->logger->error('Mail with code to sign document could not be sent: ' . $e->getMessage()); throw new LibresignException('Mail with code to sign document could not be sent', 1); From abdf722a3d9197ae519804c7ef8740971bbbd0ff Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Sat, 14 Nov 2026 22:22:56 +0000 Subject: [PATCH 2/3] fix(mail): handle rejected verification-code recipients on stable35 Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- lib/Service/MailService.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Service/MailService.php b/lib/Service/MailService.php index 2888de4576..c58e0796a7 100644 --- a/lib/Service/MailService.php +++ b/lib/Service/MailService.php @@ -298,7 +298,9 @@ public function sendCodeToSign(string $email, string $name, string $code): void } $message->useTemplate($emailTemplate); try { - $this->sendAndCheck($message); + if ($this->mailer->send($message) !== []) { + throw new \RuntimeException('Mail transport reported rejected recipients'); + } } catch (\Exception $e) { $this->logger->error('Mail with code to sign document could not be sent: ' . $e->getMessage()); throw new LibresignException('Mail with code to sign document could not be sent', 1); From 1e47a81822d7b9d85e3a1d06adc581259143dc33 Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Sat, 14 Nov 2026 22:24:05 +0000 Subject: [PATCH 3/3] test(mail): cover verification-code recipient rejection on stable35 Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- tests/php/Unit/Service/MailServiceTest.php | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/php/Unit/Service/MailServiceTest.php b/tests/php/Unit/Service/MailServiceTest.php index c3dc40c7ee..2934c3d077 100644 --- a/tests/php/Unit/Service/MailServiceTest.php +++ b/tests/php/Unit/Service/MailServiceTest.php @@ -362,6 +362,34 @@ public function testRequesterStrategyThrowsWhenFallbackAlsoFails(): void { $this->service->notifyUnsignedUser($this->mockSignRequest(), 'a@b.coop'); } + public function testSendCodeToSignAcceptsSuccessfulSubmission(): void { + $this->mockEmailTemplate(); + $message = $this->mockSystemMessage(); + $message->expects($this->once()) + ->method('setTo') + ->with(['recipient@example.com']); + $this->mailer->expects($this->once()) + ->method('send') + ->with($message) + ->willReturn([]); + + $this->service->sendCodeToSign('recipient@example.com', '', '123456'); + } + + public function testSendCodeToSignReportsRejectedRecipients(): void { + $this->mockEmailTemplate(); + $message = $this->mockSystemMessage(); + $this->mailer->expects($this->once()) + ->method('send') + ->with($message) + ->willReturn(['recipient@example.com']); + $this->logger->expects($this->once())->method('error'); + + $this->expectException(LibresignException::class); + $this->expectExceptionMessage('Mail with code to sign document could not be sent'); + $this->service->sendCodeToSign('recipient@example.com', 'Recipient', '123456'); + } + private function mockSignRequest(string $displayName = 'John Doe'): SignRequest&MockObject { $signRequest = $this->createMock(SignRequest::class); $signRequest