4

I have created custom email template in my custom module for contact form. while submitting form email should have to trigger to admin and end user and email also triggering as per requirement but it is taking header and footer from luma theme. But we need header and footer from our custom theme. Please, below attachment for more clarity: enter image description here

Thanks in advance !

2

1 Answer 1

6

I used below code to send mail to customer

$templateOptions = array(
            'area' => Area::AREA_FRONTEND, 
            'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID
        );

 $from = array('email' => $seller_email, 'name' => $post['name']);

            $this->inlineTranslation->suspend();
            $to = array($goshop_email);
            $transport = $this->_transportBuilder->setTemplateIdentifier($template_id)
                    ->setTemplateOptions($templateOptions)
                    ->setTemplateVars($templateVars)
                    ->setFrom($from)
                    ->addTo($to)
                    ->getTransport();
            $transport->sendMessage();
            $this->inlineTranslation->resume();

for

'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID

use

'store' => $this->storeManager->getStore()->getId() 

Where

$this->storeManager is alise of Magento\Store\Model\StoreManagerInterface
1
  • perfect... I was doing same mistake. Your have saved my time. Sep 1, 2020 at 5:39

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.