How to print email body data before send email in magento 2

To display the email data before sending.

Go to - vendor/magento/framework/Mail/Template/TransportBuilder.php

Function name - prepareMessage line no 275 - below line 275 add below code :

echo "TESt".$body; // test is for display purpose

exit;

After that clear cache and do any action from where email is fired it will print email details.


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

Tags:

Magento2