diff --git a/src/Illuminate/Notifications/Channels/MailChannel.php b/src/Illuminate/Notifications/Channels/MailChannel.php index 0e6b55bba4d7..f183b7520531 100644 --- a/src/Illuminate/Notifications/Channels/MailChannel.php +++ b/src/Illuminate/Notifications/Channels/MailChannel.php @@ -137,12 +137,16 @@ protected function addressMessage($mailMessage, $notifiable, $notification, $mes $mailMessage->to($this->getRecipients($notifiable, $notification, $message)); - if ($message->cc) { - $mailMessage->cc($message->cc[0], Arr::get($message->cc, 1)); + if (! empty($message->cc)) { + foreach ($message->cc as $cc) { + $mailMessage->cc($cc[0], Arr::get($cc, 1)); + } } - if ($message->bcc) { - $mailMessage->bcc($message->bcc[0], Arr::get($message->bcc, 1)); + if (! empty($message->bcc)) { + foreach ($message->bcc as $bcc) { + $mailMessage->bcc($bcc[0], Arr::get($bcc, 1)); + } } } @@ -160,7 +164,9 @@ protected function addSender($mailMessage, $message) } if (! empty($message->replyTo)) { - $mailMessage->replyTo($message->replyTo[0], Arr::get($message->replyTo, 1)); + foreach ($message->replyTo as $replyTo) { + $mailMessage->replyTo($replyTo[0], Arr::get($replyTo, 1)); + } } } diff --git a/src/Illuminate/Notifications/Messages/MailMessage.php b/src/Illuminate/Notifications/Messages/MailMessage.php index 4a0f7afc75b9..f0db201c64ed 100644 --- a/src/Illuminate/Notifications/Messages/MailMessage.php +++ b/src/Illuminate/Notifications/Messages/MailMessage.php @@ -144,7 +144,7 @@ public function from($address, $name = null) */ public function replyTo($address, $name = null) { - $this->replyTo = [$address, $name]; + $this->replyTo[] = [$address, $name]; return $this; } @@ -158,7 +158,7 @@ public function replyTo($address, $name = null) */ public function cc($address, $name = null) { - $this->cc = [$address, $name]; + $this->cc[] = [$address, $name]; return $this; } @@ -172,7 +172,7 @@ public function cc($address, $name = null) */ public function bcc($address, $name = null) { - $this->bcc = [$address, $name]; + $this->bcc[] = [$address, $name]; return $this; } diff --git a/tests/Notifications/NotificationMailMessageTest.php b/tests/Notifications/NotificationMailMessageTest.php index 3bf75d6c38a5..fc623ca94e28 100644 --- a/tests/Notifications/NotificationMailMessageTest.php +++ b/tests/Notifications/NotificationMailMessageTest.php @@ -7,17 +7,56 @@ class NotificationMailMessageTest extends TestCase { - public function setUp() + public function testTemplate() { - $this->message = new MailMessage; + $message = new MailMessage; + + $this->assertEquals('notifications::email', $message->markdown); + + $message->template('notifications::foo'); + + $this->assertEquals('notifications::foo', $message->markdown); } - public function testTemplate() + public function testCcIsSetCorrectly() + { + $message = new MailMessage; + $message->cc('test@example.com'); + + $this->assertSame([['test@example.com', null]], $message->cc); + + $message = new MailMessage; + $message->cc('test@example.com') + ->cc('test@example.com', 'Test'); + + $this->assertSame([['test@example.com', null], ['test@example.com', 'Test']], $message->cc); + } + + public function testBccIsSetCorrectly() { - $this->assertEquals('notifications::email', $this->message->markdown); + $message = new MailMessage; + $message->bcc('test@example.com'); + + $this->assertSame([['test@example.com', null]], $message->bcc); + + $message = new MailMessage; + $message->bcc('test@example.com') + ->bcc('test@example.com', 'Test'); + + $this->assertSame([['test@example.com', null], ['test@example.com', 'Test']], $message->bcc); + } + + public function testReplyToIsSetCorrectly() + { + $message = new MailMessage; + $message->replyTo('test@example.com'); + + $this->assertSame([['test@example.com', null]], $message->replyTo); - $this->message->template('notifications::foo'); + $message = new MailMessage; + $message->replyTo('test@example.com') + ->replyTo('test@example.com', 'Test'); - $this->assertEquals('notifications::foo', $this->message->markdown); + $this->assertSame([['test@example.com', null], ['test@example.com', 'Test']], $message->replyTo); } }