Skip to content

Commit 41ff9d3

Browse files
committed
minor #32002 [Mailer] made code more robust (fabpot)
This PR was merged into the 4.3 branch. Discussion ---------- [Mailer] made code more robust | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | n/a | License | MIT | Doc PR | n/a <!-- Replace this notice by a short README for your feature/bugfix. This will help people understand your PR and can be used as a start for the documentation. Additionally (see https://symfony.com/roadmap): - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against branch 4.4. - Legacy code removals go to the master branch. --> Commits ------- 8bdc659 [Mailer] made code more robust
2 parents c45c6e5 + 8bdc659 commit 41ff9d3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Symfony/Component/Mailer/SmtpEnvelope.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Symfony\Component\Mailer\Exception\InvalidArgumentException;
1515
use Symfony\Component\Mime\Address;
16-
use Symfony\Component\Mime\NamedAddress;
1716
use Symfony\Component\Mime\RawMessage;
1817

1918
/**
@@ -42,14 +41,17 @@ public static function create(RawMessage $message): self
4241

4342
public function setSender(Address $sender): void
4443
{
45-
$this->sender = $sender instanceof NamedAddress ? new Address($sender->getAddress()) : $sender;
44+
$this->sender = new Address($sender->getAddress());
4645
}
4746

4847
public function getSender(): Address
4948
{
5049
return $this->sender;
5150
}
5251

52+
/**
53+
* @param Address[] $recipients
54+
*/
5355
public function setRecipients(array $recipients): void
5456
{
5557
if (!$recipients) {
@@ -58,12 +60,10 @@ public function setRecipients(array $recipients): void
5860

5961
$this->recipients = [];
6062
foreach ($recipients as $recipient) {
61-
if ($recipient instanceof NamedAddress) {
62-
$recipient = new Address($recipient->getAddress());
63-
} elseif (!$recipient instanceof Address) {
63+
if (!$recipient instanceof Address) {
6464
throw new InvalidArgumentException(sprintf('A recipient must be an instance of "%s" (got "%s").', Address::class, \is_object($recipient) ? \get_class($recipient) : \gettype($recipient)));
6565
}
66-
$this->recipients[] = $recipient;
66+
$this->recipients[] = new Address($recipient->getAddress());
6767
}
6868
}
6969

0 commit comments

Comments
 (0)