Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] Let mailables accept a simple array of email addresses as cc or bcc #33810

Merged
merged 3 commits into from
Aug 11, 2020

Conversation

traubisoda
Copy link
Contributor

Currently we can only set a single email address, an associative array, or an object as cc or bcc in Mailables.
I think it would be nice, if it were possible just to pass a simple array of email addresses as cc/bcc. As of now, if someone has a simple array, it has to be mapped to have an email key with the address.

Example:

// This is valid
Mail::to('[email protected]')->cc('[email protected]')->send(new SomeMailable());

// This is valid
Mail::to('[email protected]')->cc('[email protected]')->send(new SomeMailable());

// This throws an exception: "Trying to get property 'email' of non-object"
Mail::to('[email protected]')->cc(['[email protected]', '[email protected]'])->send(new SomeMailable());

// Possible workaround, me no gusta
Mail::to('[email protected]')->cc(
  collect(['[email protected]', '[email protected]'])->map(fn ($email) => compact('email'))
)->send(new SomeMailable());

Since Mailable does not require a recipient name anywhere, and already accepts a single email address as cc/bcc, it would make sense if it accepted a simple array of addresses in my opinion.

@driesvints driesvints changed the title Let mailables accept a simple array of email addresses as cc or bcc [7.x] Let mailables accept a simple array of email addresses as cc or bcc Aug 10, 2020
@taylorotwell taylorotwell merged commit 44c32a2 into laravel:7.x Aug 11, 2020
@traubisoda traubisoda deleted the plain_cc_email_address_array branch August 11, 2020 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants