Im trying to send email using transportbuilder but I'm getting this error.

Exception #0 (Magento\Framework\Exception\MailException): No body specified Exception #1 (Zend_Mail_Transport_Exception): No body specified

The template is already in and everything is already put in. Im using the following code to send email.

$transport = $this->_transportBuilder->setTemplateIdentifier($templateId)
                    ->setTemplateOptions(['area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, 'store' => $storeId])
                    ->addTo($email, $name)


Can anyone help me on this.


Issue is in template id..

Template does not set properly.That why it is showing error.

If you have define email from email_templates.xml then

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:etc/email_templates.xsd">
    <template id="[TEMPLATE_ID]" label="[TEMPLATE_ID]" file="[TemplateHTMLFILE].html" type="html" module="Vendor_Module" area="frontend"/>

Then, [TEMPLATE_ID] is template id you should it at setTemplateIdentifier($templateId)

Also,Change and try it

'store' => $storeId



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.