-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Labels
Issue: Format is validGate 1 Passed. Automatic verification of issue format passedGate 1 Passed. Automatic verification of issue format passedReported on 2.3.3Indicates original Magento version for the Issue report.Indicates original Magento version for the Issue report.
Description
Preconditions (*)
- Magento Community Edition 2.3.3
- One or more Magento email templates configured as type "text" via an email_templates.xml file.
Steps to reproduce (*)
1.Attempt to send a template based email of type "text" using Magento\Framework\Mail\Template\TransportBuilder that is of Content-Type "text/plain" using the TransportBuilder class's sendMessage method.
Expected result (*)
- An email is dispatched whose "Content-Type" header is set to "text/plain"
Actual result (*)
- The email is sent with a "Content-Type" header set to "text/html"
Additional Information (*)
It appears that as of Magento 2.3.3, it is no longer possible to send "text/plain" emails using the TransportBuilder. This is because, as of 2.3.3, the TransportBuilder's prepareMessage method does not pass the determined template type to the mimePartInterfaceFactory's create method.
Current method definition as of 2.3.3:
protected function prepareMessage()
{
$template = $this->getTemplate();
$content = $template->processTemplate();
switch ($template->getType()) {
case TemplateTypesInterface::TYPE_TEXT:
$part['type'] = MimeInterface::TYPE_TEXT;
break;
case TemplateTypesInterface::TYPE_HTML:
$part['type'] = MimeInterface::TYPE_HTML;
break;
default:
throw new LocalizedException(
new Phrase('Unknown template type')
);
}
$mimePart = $this->mimePartInterfaceFactory->create(['content' => $content]);
$this->messageData['body'] = $this->mimeMessageInterfaceFactory->create(
['parts' => [$mimePart]]
);
$this->messageData['subject'] = html_entity_decode(
(string)$template->getSubject(),
ENT_QUOTES
);
$this->message = $this->emailMessageInterfaceFactory->create($this->messageData);
return $this;
}
Proposed change that would resolve issue (only the relevant snippet):
$mimePart = $this->mimePartInterfaceFactory->create(
[
'content' => $content,
'type' => $part['type']
]
);
(Pull request incoming)
rhoerr and KaiShoya
Metadata
Metadata
Assignees
Labels
Issue: Format is validGate 1 Passed. Automatic verification of issue format passedGate 1 Passed. Automatic verification of issue format passedReported on 2.3.3Indicates original Magento version for the Issue report.Indicates original Magento version for the Issue report.