Skip to content

Commit 68b3d75

Browse files
committed
Use mail from name even if it was not specified
1 parent 95ca3ae commit 68b3d75

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/EmailComposer.php

Lines changed: 7 additions & 5 deletions
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

Lines changed: 1 addition & 1 deletion
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('Example', $email->from['name']);
110110

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

tests/SenderTest.php

Lines changed: 1 addition & 1 deletion
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]

0 commit comments

Comments
 (0)