laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.51k stars 11.02k forks source link

[5.3] The Mail::to() doesn't accept an array of emails #15673

Closed atthakorn closed 8 years ago

atthakorn commented 8 years ago

The Mail::to() doesn't accept an array of emails

Steps To Reproduce:

$emails =  ['a@a.com', 'b@b.com']
Mail::to($emails)->send(new ContactMail());

the result, no email sent to recipients in $emails array.

I have looked into code in \Illuminate\Mail\Mailable->setAddress() . If $address is an array, it will fall into this condition

if ($address instanceof Collection || is_array($address)) {
            foreach ($address as $user) {
                $this->{$property}($user->email, $user->name);
            }
} 

as $address is array of emails not users, $address will not have email and name properties. therefore, none of emails added into $this->{$property}[] array, where properties is to, cc, bcc, replyTo.

please prioritize to fix!

remoblaser commented 8 years ago

I guess you could just create an object and add these properties to fix it for now. The easy solution would be to add an additional if clause to check whether $user is an object.

Edit: Looks like this has already been fixed on 66cac12

themsaid commented 8 years ago

Please upgrade to latest version.

atthakorn commented 8 years ago

thanks guy.