How to print email body data before send email i am working on local i want see the email data what data is going on email
i tried to print $transport
but its not working can someone please let me know how we can trying email data
4 Answers
To display the email data before sending.
Go to - vendor/magento/framework/Mail/Template/TransportBuilder.php
Function name - prepareMessage line no 412 - below line 412 add below code :
echo $content;
exit;
After that clear cache and do any action from where email is fired it will print email details.
-
-
@Markhenry - Are you using community edition right ? - its working and i am using it for debug purpose. which version you are using ? Commented Mar 28, 2018 at 14:06
-
-
i am able to print body now but order items its not showing in body why ? Commented Mar 29, 2018 at 7:36
-
i made it work thanks for the path that linked to my issue Commented Mar 29, 2018 at 11:57
Magento\Email\Model\Transport:: sendMessage()
line 94 adding
echo quoted_printable_decode($this->message ->getBodyText());
die;
We can able to print email template in Magento 2.3
For all those facing this issue, they can use
echo $template->processTemplate(); die;
in the file prepareMessage() function that will be around 378 line number in
vendor/magento/framework/Mail/Template/TransportBuilder
This is tested and working for Magento version 2.3.5-p1
-
1
You can print the email text from file : vendor/magento/framework/Mail/Template/TransportBuilder.php
In Magento\Framework\Mail\Template\TransportBuilder:: prepareMessage()
echo $template->processTemplate(); die;