Skip to content

Commit 29ac9f2

Browse files
Merge pull request #61 from stackkit/7.x-dev
Use mail from name even if it was not specified
2 parents 2816911 + c1b30e6 commit 29ac9f2

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

src/EmailComposer.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,15 @@ public function send(): Email
152152
(new MailableReader())->read($this);
153153
}
154154

155-
if (! $this->email->from) {
156-
$this->email->from = [
157-
'address' => config('mail.from.address'),
158-
'name' => config('mail.from.name'),
159-
];
155+
if (! is_array($this->email->from)) {
156+
$this->email->from = [];
160157
}
161158

159+
$this->email->from = [
160+
'name' => $this->email->from['name'] ?? config('mail.from.name'),
161+
'address' => $this->email->from['address'] ?? config('mail.from.address'),
162+
];
163+
162164
$this->email->save();
163165

164166
$this->email->refresh();

tests/MailableReaderTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function it_extracts_the_from_address_and_or_name()
106106

107107
$this->assertTrue((bool) $email->from);
108108
$this->assertEquals('[email protected]', $email->from['address']);
109-
$this->assertEquals(null, $email->from['name']);
109+
$this->assertEquals('Laravel', $email->from['name']);
110110

111111
$email = Email::compose()->mailable(
112112
($this->mailable())

tests/SenderTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function the_email_has_a_correct_from_email_and_from_name()
6868
$this->artisan('email:send');
6969
$from = reset($this->sent)->from;
7070
$this->assertEquals('[email protected]', key($from));
71-
$this->assertEquals(null, $from[key($from)]);
71+
$this->assertEquals('From CI test', $from[key($from)]);
7272
}
7373

7474
#[Test]

tests/TestCase.php

+2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ protected function getEnvironmentSetUp($app)
8686
]);
8787

8888
$app['config']->set('mail.driver', 'log');
89+
90+
$app['config']->set('mail.from.name', 'Laravel');
8991
}
9092

9193
public function createEmail($overwrite = [])

0 commit comments

Comments
 (0)