1

I have my custom module on Magento 2.3 and my custom module should send email from frontend. On this code, the module stops working

            $transportToStore = $this->transportBuilder
                ->setTemplateIdentifier('send_pro_email_store_template')
0

Defin Variable protected $_transportBuilder;

In __construct Define \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder

And Define $this->_transportBuilder = $transportBuilder;

In Your File :-

protected $_transportBuilder;

public function __construct(
    \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder
    array $data = []
   ){
      $this->_transportBuilder = $transportBuilder;
      parent::__construct($data);
   }

   public function yourFunction()
   {
      $transport = $this->_transportBuilder->setTemplateIdentifier('send_pro_email_store_template')
                ->setTemplateOptions($templateOptions)
                ->setTemplateVars($templateVars)
                ->setFrom($from)
                ->addTo($to)
                ->addBcc($bcc)
                ->getTransport();
      $transport->sendMessage();
   }
  • yes i have defined it in constructor, and this still not work – Tomalo Apr 4 at 10:13
  • are you using Smtp pro ? and what is version of magento ? – Rk Rathod Apr 4 at 10:15
  • I using Smtp from MagePal and this send me mail when i buy something. Magento 2.3 – Tomalo Apr 4 at 10:31
  • check test mail send or not ? – Rk Rathod Apr 4 at 10:32
  • yes, test mail work – Tomalo Apr 4 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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