Skip to content

[9.x ] Updated Mailable to prevent duplicated recipients - #45119

Merged
taylorotwell merged 5 commits into
laravel:9.xfrom
WendellAdriel:prevent-duplicate-recipient
Nov 28, 2022
Merged

[9.x ] Updated Mailable to prevent duplicated recipients#45119
taylorotwell merged 5 commits into
laravel:9.xfrom
WendellAdriel:prevent-duplicate-recipient

Conversation

@WendellAdriel

Copy link
Copy Markdown
Member

As discussed on #45042 these changes prevent the use of duplicated recipients in the to, from, cc, bcc and replyTo properties of the mailable.

@driesvints driesvints left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks okay to me. At least worth a try.

@driesvints driesvints linked an issue Nov 28, 2022 that may be closed by this pull request
@WendellAdriel

Copy link
Copy Markdown
Member Author

Thank you so much @driesvints!!!

@taylorotwell

Copy link
Copy Markdown
Member

But now these tests no longer check that two "to" addresses can actually be added.

@taylorotwell
taylorotwell marked this pull request as draft November 28, 2022 14:30
@WendellAdriel

Copy link
Copy Markdown
Member Author

That’s true @taylorotwell, sorry!
I’ll update the tests and the PR ASAP

@WendellAdriel
WendellAdriel marked this pull request as ready for review November 28, 2022 15:22
@taylorotwell
taylorotwell merged commit defd920 into laravel:9.x Nov 28, 2022
@AAllport

AAllport commented Jan 31, 2023

Copy link
Copy Markdown
Contributor

It looks like this may have introduced a bug/breaking change...

If you have the following: Mail::to($recipient)->send(new FooMail($recipient))
You can no longer set the "name" of the recipient in the build method when calling ->to($reciepent->mail, $recipient->full_name)

It looks like the call to ->unique() is removing the instance of the address with the name.

Was this intended behaviour?
It feels like if you are calling ->to(), then the most recent addition should take priority.

Suggested fix in #45885

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.

Duplicate replyTo when running render() prior to send

4 participants