Loading src/Plugin/Mail/SMTPMailSystem.php +6 −0 Changes for src/Plugin/Mail/SMTPMailSystem.php: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -318,6 +318,12 @@ class SMTPMailSystem implements MailInterface, ContainerFactoryPluginInterface { // Parse the headers of the message and set the PHPMailer object's settings // accordingly. foreach ($headers as $key => $value) { if ($value == NULL || $value == '') { // $value should always be set. If not, remove the header field and // skip to the next header field. unset($headers[$key]); continue; } switch ($key) { case 'from': if ($from == NULL or $from == '') { Loading tests/src/Unit/Plugin/Mail/SMTPMailSystemTest.php +37 −0 Changes for tests/src/Unit/Plugin/Mail/SMTPMailSystemTest.php: 37 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -277,6 +277,43 @@ class SMTPMailSystemTest extends UnitTestCase { self::assertTrue($result); } /** * Test mail() with missing header value. */ public function testMailHeader() { $mailSystem = new SMTPMailSystemTestHelper( [], '', [], $this->mockLogger->reveal(), $this->mockMessenger->reveal(), new EmailValidatorPhpMailerDefault(), $this->mockConfigFactory, $this->mockCurrentUser->reveal(), $this->mockFileSystem->reveal(), $this->mimeTypeGuesser->reveal() ); $message = [ 'to' => 'test@drupal.org', 'from' => 'PhpUnit Localhost <phpunit@localhost.com>', 'body' => 'Some test content for testMailHeaderDrupal', 'headers' => [ 'content-type' => 'text/plain', 'from' => 'test@drupal.org', 'reply-to' => 'test@drupal.org', 'cc' => '', 'bcc' => '', ], 'subject' => 'testMailHeaderDrupal', ]; // Call function. $result = $mailSystem->mail($message); self::assertTrue($result); } } /** Loading Loading
src/Plugin/Mail/SMTPMailSystem.php +6 −0 Changes for src/Plugin/Mail/SMTPMailSystem.php: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -318,6 +318,12 @@ class SMTPMailSystem implements MailInterface, ContainerFactoryPluginInterface { // Parse the headers of the message and set the PHPMailer object's settings // accordingly. foreach ($headers as $key => $value) { if ($value == NULL || $value == '') { // $value should always be set. If not, remove the header field and // skip to the next header field. unset($headers[$key]); continue; } switch ($key) { case 'from': if ($from == NULL or $from == '') { Loading
tests/src/Unit/Plugin/Mail/SMTPMailSystemTest.php +37 −0 Changes for tests/src/Unit/Plugin/Mail/SMTPMailSystemTest.php: 37 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -277,6 +277,43 @@ class SMTPMailSystemTest extends UnitTestCase { self::assertTrue($result); } /** * Test mail() with missing header value. */ public function testMailHeader() { $mailSystem = new SMTPMailSystemTestHelper( [], '', [], $this->mockLogger->reveal(), $this->mockMessenger->reveal(), new EmailValidatorPhpMailerDefault(), $this->mockConfigFactory, $this->mockCurrentUser->reveal(), $this->mockFileSystem->reveal(), $this->mimeTypeGuesser->reveal() ); $message = [ 'to' => 'test@drupal.org', 'from' => 'PhpUnit Localhost <phpunit@localhost.com>', 'body' => 'Some test content for testMailHeaderDrupal', 'headers' => [ 'content-type' => 'text/plain', 'from' => 'test@drupal.org', 'reply-to' => 'test@drupal.org', 'cc' => '', 'bcc' => '', ], 'subject' => 'testMailHeaderDrupal', ]; // Call function. $result = $mailSystem->mail($message); self::assertTrue($result); } } /** Loading