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' => \Magento\Framework\App\Area::AREA_FRONTEND,
'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID,
]
)
->setTemplateVars($vars)
->setFrom($sender)
->addTo($toEmail)
->getTransport();
$transport->sendMessage();
$this->inlineTranslation->resume();
Best Answer
You can write email subject to in your email .html file
You can pass subject dynamic by follow below example