Posted on

How to add subject in custom email template?

I have created custom email template in magento2. Mail function is working fine, but subject is not sent in that email. How can I add the subject in my custom email template.

$transport = $this->transportBuilder
->setTemplateIdentifier(‘my_custom_email_template’)
->setTemplateOptions(
[
‘area’ => MagentoFrameworkAppArea::AREA_FRONTEND,
‘store’ => MagentoStoreModelStore::DEFAULT_STORE_ID,
]
)
->setTemplateVars($vars)
->setFrom($sender)
->addTo($toEmail)
->getTransport();
$transport->sendMessage();
$this->inlineTranslation->resume();

Leave a Reply

Your email address will not be published. Required fields are marked *