Skip to content

Commit e4f160b

Browse files
committed
pass test
1 parent 7da8272 commit e4f160b

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

src/Illuminate/Mail/Message.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php namespace Illuminate\Mail;
22

3+
use Illuminate\Support\Collection;
34
use Illuminate\Support\Str;
45
use Symfony\Component\Mime\Address;
56
use Symfony\Component\Mime\Email;
@@ -118,7 +119,7 @@ public function replyTo(string $address, ?string $name = null): self
118119
/**
119120
* Add a recipient to the message.
120121
*
121-
* @param string|Address[] $address
122+
* @param string|Address[]|array<email, string> $address
122123
* @param string $name
123124
* @param string $type
124125
* @return $this
@@ -128,7 +129,22 @@ protected function addAddresses(string|array $address, ?string $name, string $ty
128129
if (is_array($address))
129130
{
130131
$type = lcfirst($type);
131-
$this->message->$type($address);
132+
$addresses = (new Collection($address))->map(function ($address, $key) {
133+
if (is_string($key) && is_string($address)) {
134+
return new Address($key, $address);
135+
}
136+
137+
if (is_array($address)) {
138+
return new Address($address['email'] ?? $address['address'], $address['name'] ?? null);
139+
}
140+
141+
if (is_null($address)) {
142+
return new Address($key);
143+
}
144+
145+
return $address;
146+
})->all();
147+
$this->message->$type(...$addresses);
132148
}
133149
else
134150
{

0 commit comments

Comments
 (0)