I have a string HTML
and have to convert(parse) it to HTML in PHP.
$stringHtml
How to convert this to HTML so that it all <p>
, <br>
tag works
this is Riskified decline email, and whatever content I add in its admin panel it prints as it is in email.
so I have added html_entity_decode
in $content
code
$transport = $this->transportBuilder
->setTemplateIdentifier('riskified_order_declined') // this code we have mentioned in the email_templates.xml
->setTemplateOptions(
[
'area' => \Magento\Framework\App\Area::AREA_FRONTEND, // this is using frontend area to get the template file
'store' => $order->getStoreId(),
]
)
->setTemplateVars(
[
"content" => html_entity_decode($content),
"subject" => $subject,
]
)
->setFrom(
[
"email" => $this->apiConfig->getDeclineNotificationSenderEmail(),
"name" => $this->apiConfig->getDeclineNotificationSenderName(),
]
)
->addTo($order->getCustomerEmail(), $order->getCustomerName())
->getTransport();
This is what my email looks like. no formatting it just prints the
tag.
Riskfied email_template.xml
<config
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:etc/email_templates.xsd">
<template
id="riskified_order_declined"
label="Notification sent to customer when order was declined"
file="order/declined.html"
type="html"
module="Riskified_Decider"
area="frontend"
/>
declined.html
<!--@subject {{var subject}} @-->
{{template config_path="design/email/header_template"}}
{{var content}}
{{template config_path="design/email/footer_template"}}