Skip to content

Commit 00dd2a9

Browse files
committed
Merge remote-tracking branch 'origin/mail_interface_cleanup' into mail_interface_cleanup
2 parents 89061b2 + 2a9a85b commit 00dd2a9

File tree

3 files changed

+42
-29
lines changed

3 files changed

+42
-29
lines changed

dev/tests/integration/testsuite/Magento/Framework/Mail/EmailMessageTest.php

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,19 @@ public function getEmailMessageDataProvider(): array
118118
*/
119119
public function testEmailMessage($content, $type): void
120120
{
121-
$mimePart = $this->mimePartFactory->create([
122-
'content' => $content,
123-
'description' => $this->description,
124-
'type' => $type
125-
]);
121+
$mimePart = $this->mimePartFactory->create(
122+
[
123+
'content' => $content,
124+
'description' => $this->description,
125+
'type' => $type
126+
]
127+
);
126128

127-
$mimeMessage = $this->mimeMessageFactory->create([
128-
'parts' => [$mimePart]
129-
]);
129+
$mimeMessage = $this->mimeMessageFactory->create(
130+
[
131+
'parts' => [$mimePart]
132+
]
133+
);
130134

131135
$this->addressFactory = $this->di->get(AddressFactory::class);
132136
/** @var Address $addressTo */
@@ -194,21 +198,27 @@ public function testEmailMessage($content, $type): void
194198
*/
195199
public function testEmailMessageWithAttachment(): void
196200
{
197-
$mimePartMain = $this->mimePartFactory->create([
198-
'content' => 'Test',
199-
'description' => $this->description,
200-
'type' => MimeInterface::TYPE_TEXT
201-
]);
202-
$mimePartAttachment = $this->mimePartFactory->create([
203-
'content' => $this->getXmlContent(),
204-
'disposition' => MimeInterface::DISPOSITION_ATTACHMENT,
205-
'fileName' => self::ATTACHMENT_FILE_NAME,
206-
'type' => self::XML_TYPE
207-
]);
201+
$mimePartMain = $this->mimePartFactory->create(
202+
[
203+
'content' => 'Test',
204+
'description' => $this->description,
205+
'type' => MimeInterface::TYPE_TEXT
206+
]
207+
);
208+
$mimePartAttachment = $this->mimePartFactory->create(
209+
[
210+
'content' => $this->getXmlContent(),
211+
'disposition' => MimeInterface::DISPOSITION_ATTACHMENT,
212+
'fileName' => self::ATTACHMENT_FILE_NAME,
213+
'type' => self::XML_TYPE
214+
]
215+
);
208216

209-
$mimeMessage = $this->mimeMessageFactory->create([
210-
'parts' => [$mimePartMain, $mimePartAttachment]
211-
]);
217+
$mimeMessage = $this->mimeMessageFactory->create(
218+
[
219+
'parts' => [$mimePartMain, $mimePartAttachment]
220+
]
221+
);
212222

213223
$this->addressFactory = $this->di->get(AddressFactory::class);
214224
/** @var Address $addressTo */
@@ -242,7 +252,8 @@ public function testEmailMessageWithAttachment(): void
242252
private function getXmlContent(): string
243253
{
244254
return '<?xml version="1.0"?>
245-
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
255+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
256+
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
246257
<type name="Magento\Framework\Console\CommandList">
247258
<arguments>
248259
<argument name="commands" xsi:type="array">

lib/internal/Magento/Framework/Mail/EmailMessage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function __construct(
8989
$this->message->setReplyTo($this->convertAddressArrayToAddressList($replyTo));
9090
}
9191
if ($replyTo) {
92-
$this->message->setFrom($this->convertAddressArrayToAddressList($replyTo));
92+
$this->message->setFrom($this->convertAddressArrayToAddressList($from));
9393
}
9494
if ($cc) {
9595
$this->message->setCc($this->convertAddressArrayToAddressList($cc));

lib/internal/Magento/Framework/Mail/Template/TransportBuilder.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -416,14 +416,16 @@ protected function prepareMessage()
416416
*/
417417
private function addAddressByType(string $addressType, $email, ?string $name = null): void
418418
{
419-
if (is_array($email)) {
419+
if (is_string($email)) {
420+
$this->messageData[$addressType][] = $this->addressConverter->convert($email, $name);
421+
return;
422+
}
423+
$convertedAddressArray = $this->addressConverter->convertMany($email);
424+
if (isset($this->messageData[$addressType])) {
420425
$this->messageData[$addressType] = array_merge(
421426
$this->messageData[$addressType],
422-
$this->addressConverter->convertMany($email)
427+
$convertedAddressArray
423428
);
424-
425-
return;
426429
}
427-
$this->messageData[$addressType][] = $this->addressConverter->convert($email, $name);
428430
}
429431
}

0 commit comments

Comments
 (0)