Skip to main content

Use the method clearSubject(), but to apply when you are to call getMessage() method, let this example over here

$transport = $this->transportBuilder->setTemplateIdentifier('send_email_email_template')
            ->transportBuilder
    ->setTemplateIdentifier('send_email_email_template')
    ->setTemplateOptions( [
                                                'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
                                                'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID,
                                          ])
                    ->setTemplateVars(array())
                    ->setFrom($sender)
                    ->addTo($toEmail, '')
                    ->getTransport();
$transport
    ->getMessage()
    ->setMessageType( \Magento\Framework\Mail\MessageInterface::TYPE_HTML)
    ->setBody($MyHtml)
    ->clearSubject()
    ->setSubject("MySubject");
$transport->sendMessage();

Use the method clearSubject(), but to apply when you are to call getMessage() method, let this example over here

$transport = $this->transportBuilder->setTemplateIdentifier('send_email_email_template')
                    ->setTemplateOptions( [
                                                'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
                                                'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID,
                                          ])
                    ->setTemplateVars(array())
                    ->setFrom($sender)
                    ->addTo($toEmail, '')
                    ->getTransport();
$transport->getMessage()->setMessageType( \Magento\Framework\Mail\MessageInterface::TYPE_HTML)->setBody($MyHtml)->clearSubject()->setSubject("MySubject");
$transport->sendMessage();

Use the method clearSubject(), but to apply when you are to call getMessage() method, let this example over here

$transport = $this
    ->transportBuilder
    ->setTemplateIdentifier('send_email_email_template')
    ->setTemplateOptions( [
        'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
        'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID,
    ])
    ->setTemplateVars(array())
    ->setFrom($sender)
    ->addTo($toEmail, '')
    >getTransport();
$transport
    ->getMessage()
    ->setMessageType( \Magento\Framework\Mail\MessageInterface::TYPE_HTML)
    ->setBody($MyHtml)
    ->clearSubject()
    ->setSubject("MySubject");
$transport->sendMessage();
improve Quetion
Source Link
Msquare
  • 9.3k
  • 7
  • 27
  • 68

Use the method clearSubject(), but to apply when you are to call getMessage() method, let this example over here

Use the method clearSubject(), but to apply when you are to call getMessage() method, let this example over here

$transport = $this->transportBuilder->setTemplateIdentifier('send_email_email_template') ->setTemplateOptions( [ 'area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID, ]) ->setTemplateVars(array()) ->setFrom($sender) ->addTo($toEmail, '') ->getTransport(); $transport->getMessage()->setMessageType( \Magento\Framework\Mail\MessageInterface::TYPE_HTML)->setBody($MyHtml)->clearSubject()->setSubject("MySubject"); $transport->sendMessage();

$transport = $this->transportBuilder->setTemplateIdentifier('send_email_email_template')
                    ->setTemplateOptions( [
                                                'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
                                                'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID,
                                          ])
                    ->setTemplateVars(array())
                    ->setFrom($sender)
                    ->addTo($toEmail, '')
                    ->getTransport();
$transport->getMessage()->setMessageType( \Magento\Framework\Mail\MessageInterface::TYPE_HTML)->setBody($MyHtml)->clearSubject()->setSubject("MySubject");
$transport->sendMessage();

Use the method clearSubject(), but to apply when you are to call getMessage() method, let this example over here

$transport = $this->transportBuilder->setTemplateIdentifier('send_email_email_template') ->setTemplateOptions( [ 'area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID, ]) ->setTemplateVars(array()) ->setFrom($sender) ->addTo($toEmail, '') ->getTransport(); $transport->getMessage()->setMessageType( \Magento\Framework\Mail\MessageInterface::TYPE_HTML)->setBody($MyHtml)->clearSubject()->setSubject("MySubject"); $transport->sendMessage();

Use the method clearSubject(), but to apply when you are to call getMessage() method, let this example over here

$transport = $this->transportBuilder->setTemplateIdentifier('send_email_email_template')
                    ->setTemplateOptions( [
                                                'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
                                                'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID,
                                          ])
                    ->setTemplateVars(array())
                    ->setFrom($sender)
                    ->addTo($toEmail, '')
                    ->getTransport();
$transport->getMessage()->setMessageType( \Magento\Framework\Mail\MessageInterface::TYPE_HTML)->setBody($MyHtml)->clearSubject()->setSubject("MySubject");
$transport->sendMessage();
Source Link

Use the method clearSubject(), but to apply when you are to call getMessage() method, let this example over here

$transport = $this->transportBuilder->setTemplateIdentifier('send_email_email_template') ->setTemplateOptions( [ 'area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID, ]) ->setTemplateVars(array()) ->setFrom($sender) ->addTo($toEmail, '') ->getTransport(); $transport->getMessage()->setMessageType( \Magento\Framework\Mail\MessageInterface::TYPE_HTML)->setBody($MyHtml)->clearSubject()->setSubject("MySubject"); $transport->sendMessage();