Showing results for 
Search instead for 
Did you mean: 

How to convert transaction email to text file

How to convert transaction email to text file

Hello all,


I need to  convert   transctional email to text file , while sending customer , How to do that?


Now, What I done So far,


 Open , Magento-sales -> Model -> Order -> Email -> SenderBuilder  and  edit within Send() method


This is my code.


public function send()


        $copyTo = $this->identityContainer->getEmailCopyTo();

        if (!empty($copyTo) && $this->identityContainer->getCopyMethod() == 'bcc') {
            foreach ($copyTo as $email) {

        $transport = $this->transportBuilder->getTransport();
        $this->file = $transport;
        function __toString()
            $Msg= $this->file;
            $myfile = fopen("email.txt", "w") or die("Unable to open file!");
            $txt = $Msg;
            fwrite($myfile, $txt);


 Then , I send order status via Admin panel , that email sent Customer Account, But,  Not create a file.

I try to convert  $transport Obejct to String , then Store to File, But not working. No file created


I think  I am going wrong Way, because I dont know Which Class Collect all email template and Send to the Customer, I need to That Object then, only I Convert to String to Strore a File.


So, Suggest me, Which class and Method?, Where I go to Edit?.