From 69624116db9176d6a3562e76226a012a2c3af436 Mon Sep 17 00:00:00 2001 From: jf-cbd <121934370+jf-cbd@users.noreply.github.com> Date: Mon, 24 Aug 2026 17:42:05 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B09919=20-=20Check=20if=20"To"=20exists=20?= =?UTF-8?q?when=20sendind=20mail=20with=20PHPMail=20(#1021)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Transport/SymfonyPHPMailTransport.php | 2 +- .../Transport/SymfonyPHPMailTransportTest.php | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 tests/php-unit-tests/unitary-tests/sources/core/Email/Transport/SymfonyPHPMailTransportTest.php diff --git a/sources/Core/Email/Transport/SymfonyPHPMailTransport.php b/sources/Core/Email/Transport/SymfonyPHPMailTransport.php index 7f2334ff25..7881ba4299 100644 --- a/sources/Core/Email/Transport/SymfonyPHPMailTransport.php +++ b/sources/Core/Email/Transport/SymfonyPHPMailTransport.php @@ -20,7 +20,7 @@ class SymfonyPHPMailTransport extends AbstractTransport { $oHeaders = $oRawEmail->getHeaders(); - return $oHeaders->get('To')->getBodyAsString(); + return $oHeaders->get('To') ? $oHeaders->get('To')->getBodyAsString() : ''; } /** diff --git a/tests/php-unit-tests/unitary-tests/sources/core/Email/Transport/SymfonyPHPMailTransportTest.php b/tests/php-unit-tests/unitary-tests/sources/core/Email/Transport/SymfonyPHPMailTransportTest.php new file mode 100644 index 0000000000..97f1db109d --- /dev/null +++ b/tests/php-unit-tests/unitary-tests/sources/core/Email/Transport/SymfonyPHPMailTransportTest.php @@ -0,0 +1,22 @@ +from('sender@example.com') + ->cc('cc1@example.com', 'cc2@example.com') + ->text('Body'); + + $oTransport = new SymfonyPHPMailTransport(); + + $oTransport->prepareTo($oEmail); + $this->assertTrue(true); // if no error is thrown, the test passes + + } +}