5

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 4

10

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.

6
  • no luck @manthan
    – Mark henry
    Commented Mar 28, 2018 at 14:06
  • @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
  • magento version :2.1.4
    – Mark henry
    Commented Mar 28, 2018 at 14:34
  • i am able to print body now but order items its not showing in body why ?
    – Mark henry
    Commented Mar 29, 2018 at 7:36
  • i made it work thanks for the path that linked to my issue
    – Mark henry
    Commented Mar 29, 2018 at 11:57
7

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

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
  • 1
    i am able to print body now. Thanks @vivek Commented Nov 26, 2020 at 4:32
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;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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