Skip to content

Commit

Permalink
Revert "Fix setting mail header (#32272)"
Browse files Browse the repository at this point in the history
This reverts commit bf4b6d1.
  • Loading branch information
driesvints authored Apr 7, 2020
1 parent 27edffe commit b2a17e8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
11 changes: 3 additions & 8 deletions src/Illuminate/Mail/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

Expand Down
5 changes: 0 additions & 5 deletions tests/Mail/MailMailerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit b2a17e8

Please sign in to comment.