Typically we have to present buyer title, order id, OTP and so on in e-mail topic or physique.
Step 1 -> Register template in e-mail. Webkul/Howdy/and so on/email_templates.xml
<?xml model="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:and so on/email_templates.xsd"> <template id="hello_template" label="Howdy World" file="hey.html" kind="html" module="Webkul_Hello" space="frontend"/> </config>
Step 2 -> Load e-mail content material in Webkul/Howdy/view/frontend/e-mail/hey.html
<[email protected] {{trans "Buyer has uploaded attachment on %order_id" order_id=$orderId }} @--> <[email protected] physique,td { coloration:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; } @--> {{template config_path="design/e-mail/header_template"}} <desk cellspacing="0" cellpadding="0" border="0" width="100%"> <tr> <td align="middle" valign="prime" fashion="padding:20px 0 20px 0"> <desk bgcolor="#FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" fashion="border:1px stable #E0E0E0;"> <tr> <td valign="prime"> <h1 fashion="font-size:22px;font-weight:regular;line-height:22px;margin:0 0 11px 0;">{{trans "Howdy"}},</h1> </td> </tr> <tr> <td> <desk cellspacing="0" cellpadding="0" border="0" width="650"> <tbody> <tr> <td colspan="2" valign="prime" fashion="font-size:24px;padding:7px 9px 9px 9px;border:1px stable #EAEAEA;"> <b>{{trans "Order Id: "}}{{var orderId}}</b> </td> </tr> <tr> <td colspan="2" valign="prime" fashion="font-size:12px;padding:7px 9px 9px 9px;border:1px stable #EAEAEA;"> {{trans "A Buyer %customer_name has uploaded attachment so as %order_id" customer_name=$customer_name order_id=$orderId}} </td> </tr> </tbody> </desk> </td> </tr> <tr> <td bgcolor="#EAEAEA" align="middle" fashion="background:#EAEAEA;text-align:middle;"> <middle> <p fashion="font-size:12px;margin:0;"> <sturdy>{{trans "Thanks"}}</sturdy> </p> </middle> </td> </tr> </desk> </td> </tr> </desk> {{template config_path="design/e-mail/footer_template"}}
Step 3 -> Load template with dynamic variables and ship mail.
/** @var $storeManager MagentoStoreModelStoreManagerInterface $storeManager **/ /** @var $transportBuilder MagentoFrameworkMailTemplateTransportBuilder **/ /** @var $inlineTranslation MagentoFrameworkTranslateInlineStateInterface **/ $storeManager = $objectManager->create(MagentoStoreModelStoreManagerInterface::class); $transportBuilder = $objectManager->create(MagentoFrameworkMailTemplateTransportBuilder::class); $inlineTranslation = $objectManager->create(MagentoFrameworkTranslateInlineStateInterface::class); $templateOptions = [ 'area' => MagentoFrameworkAppArea::AREA_FRONTEND, 'store' => $storeManager->getStore()->getId() ]; $templateVars = [ 'orderId' => "#00000009", 'customer_name' => "Amir Khan" ]; $from = ['email' => "[email protected]", 'title' => 'Admin']; $inlineTranslation->droop(); $to = ['[email protected]']; $transport = $transportBuilder->setTemplateIdentifier('hello_template') ->setTemplateOptions($templateOptions) ->setTemplateVars($templateVars) ->setFrom($from) ->addTo($to) ->getTransport(); $transport->sendMessage(); $inlineTranslation->resume();
Thanks 🙂