0

I tried to send mail code in magento 2.2.8 but it throw error I am using below code for sending a mail in magneto 2.2.8

$transport = $this->_transportBuilder
                                ->setTemplateIdentifier('customemail_email_template')
                                ->setTemplateOptions(
                                    [
                                        'area' => 'frontend',
                                        'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID,
                                    ]
                                    )

                                        ->setTemplateVars([
                                            'firstname' => $post['firstname'],
                                            'lastname' => $post['lastname'],
                                    ])

                                    ->setFrom($sender)
                                    ->addTo($sentToEmail,$sentToName);
                                    try{
                                    $transport->getTransport()->sendMessage();
                                    }catch(Exception $e){
                                        var_dump($e->getMessage());die();
                                    }
                                    $this->_inlineTranslation->resume();
                                    die("Sent mail");

This above code perfect work in magento 2.2.3 version but not working in magento 2.2.8 version I am getting below error in magento 2.2.8

enter image description here

  • Im going to assume there is an issue with your template based on the error in your screenshot can you please try using a default email to test that the functionality is working if so this will make it possible for you to go back and debug your template if that is the issue – Dava Gordon Aug 20 at 20:55

Your Answer

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

Browse other questions tagged or ask your own question.