Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

Commit

Permalink
Fix mimetype
Browse files Browse the repository at this point in the history
  • Loading branch information
Mischa Braam committed Sep 7, 2020
1 parent 49e7efb commit 6a7d3ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions Mail/Template/TransportBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,23 +314,25 @@ protected function getTemplate()
protected function prepareMessage()
{
$template = $this->getTemplate();
$content = $template->processTemplate();
$mimeType = null;
switch ($template->getType()) {
case TemplateTypesInterface::TYPE_TEXT:
$part['type'] = MimeInterface::TYPE_TEXT;
$mimeType = MimeInterface::TYPE_TEXT;
break;

case TemplateTypesInterface::TYPE_HTML:
$part['type'] = MimeInterface::TYPE_HTML;
$mimeType = MimeInterface::TYPE_HTML;
break;

default:
throw new LocalizedException(
new Phrase('Unknown template type')
);
}
$mimePart = $this->mimePartInterfaceFactory->create(['content' => $content]);
$parts = count($this->attachments) ? array_merge([$mimePart], $this->attachments) : [$mimePart];

$content = $template->processTemplate();
$mimePart = $this->mimePartInterfaceFactory->create(['content' => $content, 'type' => $mimeType]);
$parts = count($this->attachments) ? array_merge([$mimePart], $this->attachments) : [$mimePart];
$this->messageData['body'] = $this->mimeMessageInterfaceFactory->create(
['parts' => $parts]
);
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "weprovide/magento2-module-mailattachment",
"description": "Extends TransportBuilder with attachment functionality",
"type": "magento2-module",
"version": "2.1.3",
"version": "2.1.4",
"authors": [
{
"email": "[email protected]",
Expand Down

0 comments on commit 6a7d3ef

Please sign in to comment.