diff --git a/src/EmailComposer.php b/src/EmailComposer.php index fc4d67c..1edb0aa 100644 --- a/src/EmailComposer.php +++ b/src/EmailComposer.php @@ -152,13 +152,15 @@ public function send(): Email (new MailableReader())->read($this); } - if (! $this->email->from) { - $this->email->from = [ - 'address' => config('mail.from.address'), - 'name' => config('mail.from.name'), - ]; + if (! is_array($this->email->from)) { + $this->email->from = []; } + $this->email->from = [ + 'name' => $this->email->from['name'] ?? config('mail.from.name'), + 'address' => $this->email->from['address'] ?? config('mail.from.address'), + ]; + $this->email->save(); $this->email->refresh(); diff --git a/tests/MailableReaderTest.php b/tests/MailableReaderTest.php index 7e15865..42a5e6b 100644 --- a/tests/MailableReaderTest.php +++ b/tests/MailableReaderTest.php @@ -106,7 +106,7 @@ public function it_extracts_the_from_address_and_or_name() $this->assertTrue((bool) $email->from); $this->assertEquals('marick@dolphiq.nl', $email->from['address']); - $this->assertEquals(null, $email->from['name']); + $this->assertEquals('Laravel', $email->from['name']); $email = Email::compose()->mailable( ($this->mailable()) diff --git a/tests/SenderTest.php b/tests/SenderTest.php index 7083b01..be8a295 100644 --- a/tests/SenderTest.php +++ b/tests/SenderTest.php @@ -68,7 +68,7 @@ public function the_email_has_a_correct_from_email_and_from_name() $this->artisan('email:send'); $from = reset($this->sent)->from; $this->assertEquals('marick@dolphiq.nl', key($from)); - $this->assertEquals(null, $from[key($from)]); + $this->assertEquals('From CI test', $from[key($from)]); } #[Test] diff --git a/tests/TestCase.php b/tests/TestCase.php index 08dbe88..abd3a67 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -86,6 +86,8 @@ protected function getEnvironmentSetUp($app) ]); $app['config']->set('mail.driver', 'log'); + + $app['config']->set('mail.from.name', 'Laravel'); } public function createEmail($overwrite = [])