X
Xaiamedia
Guest
Xaiamedia Asks: Magento 2: Transportbuilder sending empty mails
I'm trying to use the transportbuilder to send an custom email in my module. I succeed in sending an email, but the body is always empty.
This is my email_templates.xml (placed in view/frontend/email/)
And this is my mail function:
And this is my template:
The email is fully blank (no static template content aswell), but I don't get any error messages while sending. Is there a way to debug this situation?
I'm trying to use the transportbuilder to send an custom email in my module. I succeed in sending an email, but the body is always empty.
This is my email_templates.xml (placed in view/frontend/email/)
Code:
<?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="empty_email_template" label="Empty Template" file="empty.html" type="text" module="Xaiamedia_SyncProducts" area="frontend"/>
</config>
And this is my mail function:
Code:
$emailTemplateVariables = array();
$emailTempVariables['ucdata'] = 'dummy';
$sendToEmail = 'email@gmail.com';
$postObject = new \Magento\Framework\DataObject();
$postObject->setData($emailTempVariables);
$sender = array('email' => "info@mywebsite.nl", 'name' => 'Mywebsite');
$transport = $this->_transportBuilder->setTemplateIdentifier('empty_email_template')
->setTemplateOptions(['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID])
->setTemplateVars(['data' => $postObject])
->setFrom($sender)
->addTo($sendToEmail)
->setReplyTo($sender['email'])
->getTransport();
$bla = $transport->sendMessage();
And this is my template:
Code:
<strong>De volgende producten zijn verwijderd door Lightmakers:</strong> <br><br>
<pre>
{{trans "Ucdata: %ucData" ucData=$data.ucdata}}
</pre>
The email is fully blank (no static template content aswell), but I don't get any error messages while sending. Is there a way to debug this situation?
SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.