From b2a17e8da19d79fc4812e4e81b7ca75fff7ce6d1 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Tue, 7 Apr 2020 20:36:36 +0200 Subject: [PATCH] Revert "Fix setting mail header (#32272)" This reverts commit bf4b6d124e4187751ba7d9c10add8801edd5491d. --- src/Illuminate/Mail/Mailer.php | 11 +++-------- tests/Mail/MailMailerTest.php | 5 ----- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/Illuminate/Mail/Mailer.php b/src/Illuminate/Mail/Mailer.php index 34250f3ca6b0..01a32bded0a8 100755 --- a/src/Illuminate/Mail/Mailer.php +++ b/src/Illuminate/Mail/Mailer.php @@ -324,25 +324,20 @@ protected function parseView($view) */ protected function addContent($message, $view, $plain, $raw, $data) { - $header = $message->getContentType(); - if (isset($view)) { - $message->setBody( - $this->renderView($view, $data), - $header && $header !== 'text/plain' ? $header : 'text/html' - ); + $message->setBody($this->renderView($view, $data), 'text/html'); } if (isset($plain)) { $method = isset($view) ? 'addPart' : 'setBody'; - $message->$method($this->renderView($plain, $data), $header ?: 'text/plain'); + $message->$method($this->renderView($plain, $data), 'text/plain'); } if (isset($raw)) { $method = (isset($view) || isset($plain)) ? 'addPart' : 'setBody'; - $message->$method($raw, $header ?: 'text/plain'); + $message->$method($raw, 'text/plain'); } } diff --git a/tests/Mail/MailMailerTest.php b/tests/Mail/MailMailerTest.php index 74ec658fd2a5..3a3ef125f1c4 100755 --- a/tests/Mail/MailMailerTest.php +++ b/tests/Mail/MailMailerTest.php @@ -36,7 +36,6 @@ public function testMailerSendSendsMessageWithProperViewContent() $message->shouldReceive('setFrom')->never(); $this->setSwiftMailer($mailer); $message->shouldReceive('getSwiftMessage')->once()->andReturn($message); - $message->shouldReceive('getContentType')->once()->andReturn(''); $mailer->getSwiftMailer()->shouldReceive('send')->once()->with($message, []); $mailer->send('foo', ['data'], function ($m) { $_SERVER['__mailer.test'] = $m; @@ -58,7 +57,6 @@ public function testMailerSendSendsMessageWithProperViewContentUsingHtmlStrings( $message->shouldReceive('setFrom')->never(); $this->setSwiftMailer($mailer); $message->shouldReceive('getSwiftMessage')->once()->andReturn($message); - $message->shouldReceive('getContentType')->once()->andReturn(''); $mailer->getSwiftMailer()->shouldReceive('send')->once()->with($message, []); $mailer->send(['html' => new HtmlString('rendered.view'), 'text' => new HtmlString('rendered.text')], ['data'], function ($m) { $_SERVER['__mailer.test'] = $m; @@ -79,7 +77,6 @@ public function testMailerSendSendsMessageWithProperViewContentUsingHtmlMethod() $message->shouldReceive('setFrom')->never(); $this->setSwiftMailer($mailer); $message->shouldReceive('getSwiftMessage')->once()->andReturn($message); - $message->shouldReceive('getContentType')->once()->andReturn(''); $mailer->getSwiftMailer()->shouldReceive('send')->once()->with($message, []); $mailer->html('rendered.view', function ($m) { $_SERVER['__mailer.test'] = $m; @@ -102,7 +99,6 @@ public function testMailerSendSendsMessageWithProperPlainViewContent() $message->shouldReceive('setFrom')->never(); $this->setSwiftMailer($mailer); $message->shouldReceive('getSwiftMessage')->once()->andReturn($message); - $message->shouldReceive('getContentType')->once()->andReturn(''); $mailer->getSwiftMailer()->shouldReceive('send')->once()->with($message, []); $mailer->send(['foo', 'bar'], ['data'], function ($m) { $_SERVER['__mailer.test'] = $m; @@ -125,7 +121,6 @@ public function testMailerSendSendsMessageWithProperPlainViewContentWhenExplicit $message->shouldReceive('setFrom')->never(); $this->setSwiftMailer($mailer); $message->shouldReceive('getSwiftMessage')->once()->andReturn($message); - $message->shouldReceive('getContentType')->once()->andReturn(''); $mailer->getSwiftMailer()->shouldReceive('send')->once()->with($message, []); $mailer->send(['html' => 'foo', 'text' => 'bar'], ['data'], function ($m) { $_SERVER['__mailer.test'] = $m;