Manage address/name recipients array in SymfonyMailerAdapter #259
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
I'm currently working on the upgrade of a Sylius v1.10 to Sylius 1.12. Since Sylius use Symfony Mailer instead of Swift Mailer, we encounter the following bug: before the upgrade, we use
array for the
$recipients
parameter of the\Sylius\Component\Mailer\Sender\Sender::send
method, and it was working like a charm.Problem
After the upgrade, Symfony Mailer
\Symfony\Component\Mime\Email
object used in\Sylius\Bundle\MailerBundle\Sender\Adapter\SymfonyMailerAdapter::sendMessage
is looking for a\Symfony\Component\Mime\Address
objects or strings. With an array like above, it tries to use 'John Doe'
or'Jane Smith'
as email and the following exception is thrown:Fix
I've added a function to format
address => name
like array value to anAddress
object. Onlyaddress
value are not touched.