Skip to content
Permalink
Browse files

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
  • Loading branch information...
fabpot committed Jun 12, 2019
2 parents c45c6e5 + 8bdc659 commit 41ff9d31d42b29c58eeaed57f782c0af80a5ca34
Showing with 6 additions and 6 deletions.
  1. +6 −6 src/Symfony/Component/Mailer/SmtpEnvelope.php
@@ -13,7 +13,6 @@
use Symfony\Component\Mailer\Exception\InvalidArgumentException;
use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\NamedAddress;
use Symfony\Component\Mime\RawMessage;
/**
@@ -42,14 +41,17 @@ public static function create(RawMessage $message): self
public function setSender(Address $sender): void
{
$this->sender = $sender instanceof NamedAddress ? new Address($sender->getAddress()) : $sender;
$this->sender = new Address($sender->getAddress());
}
public function getSender(): Address
{
return $this->sender;
}
/**
* @param Address[] $recipients
*/
public function setRecipients(array $recipients): void
{
if (!$recipients) {
@@ -58,12 +60,10 @@ public function setRecipients(array $recipients): void
$this->recipients = [];
foreach ($recipients as $recipient) {
if ($recipient instanceof NamedAddress) {
$recipient = new Address($recipient->getAddress());
} elseif (!$recipient instanceof Address) {
if (!$recipient instanceof Address) {
throw new InvalidArgumentException(sprintf('A recipient must be an instance of "%s" (got "%s").', Address::class, \is_object($recipient) ? \get_class($recipient) : \gettype($recipient)));
}
$this->recipients[] = $recipient;
$this->recipients[] = new Address($recipient->getAddress());
}
}

0 comments on commit 41ff9d3

Please sign in to comment.
You can’t perform that action at this time.