From 4b7384026996b407c56930e16dd2a021eefc10ec Mon Sep 17 00:00:00 2001 From: Julian van den Berkmortel Date: Tue, 7 Apr 2020 15:13:10 +0200 Subject: [PATCH 1/2] Use the existing "Zend\Mime\Part" in the message body instead of creating a new instance --- Mail/Template/TransportBuilder.php | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/Mail/Template/TransportBuilder.php b/Mail/Template/TransportBuilder.php index e4325f1..b6a1d65 100644 --- a/Mail/Template/TransportBuilder.php +++ b/Mail/Template/TransportBuilder.php @@ -107,27 +107,8 @@ protected function attachAttachmentsToBody() // @see https://magento.stackexchange.com/questions/292760/unable-to-add-attachment-in-email-after-upgrade-to-magento-2-3-3-version $mimeMessage = $this->mimeMessageFactory->create(); - /** @var Part $bodyPart */ - $bodyPart = $this->partFactory->create(['content' => $this->message->getBody()]); - // Cannot inherit through $this->message. Default is utf-8. - $bodyPart->setCharset('utf-8'); - - // Re-used from prepare message, can be removed in 2.3.3. - // Because they are using parts by default. These interface type logic can be removed. - $template = $this->getTemplate(); - switch ($template->getType()) { - case TemplateTypesInterface::TYPE_TEXT: - $bodyPart->setType(Mime::TYPE_TEXT); - $mimeMessage->setParts(array_merge([$bodyPart], $this->attachments)); - $this->message->setBodyText($mimeMessage); - break; - - case TemplateTypesInterface::TYPE_HTML: - $bodyPart->setType(Mime::TYPE_HTML); - $mimeMessage->setParts(array_merge([$bodyPart], $this->attachments)); - $this->message->setBodyHtml($mimeMessage); - break; - } + $mimeMessage->setParts(array_merge($this->message->getBody()->getParts(), $this->attachments)); + $this->message->setBody($mimeMessage); } } From 34b880f53d6fe9e11b0ce13d90efa34450d721bf Mon Sep 17 00:00:00 2001 From: Julian van den Berkmortel Date: Wed, 8 Apr 2020 14:44:33 +0200 Subject: [PATCH 2/2] Add version constraint for "magento/framework" (">=102.0.0 <102.0.3") --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index 2cca4ed..e66fe8d 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,9 @@ ], "license": "MIT", "minimum-stability": "stable", + "require": { + "magento/framework": ">=102.0.0 <102.0.3" + }, "autoload": { "psr-4": { "WeProvide\\MailAttachment\\": ""