0

Getting error when trying to send email via controller

 $email_Template = 'hello_template';  
    $email_Subject = 'Customer Registration Success';

    $transport = $this->transportBuilder
        ->setTemplateIdentifier($email_Template)
        ->setTemplateOptions(['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $this->storeManager->getStore()->getId()])
        ->setTemplateVars([
            'name'  => 'aaaa',
            'email'  => $data['email'],
            'subject'  => $email_Subject
        ])
        ->setFrom(['name' => 'test','email' => '[email protected]'])
        ->addTo([$data['email']])
        ->getTransport();
    $transport->sendMessage();

How to debug the error.

I have already tried by removing generated folder & re run all magento2 compilation commands

I am using Magento2.3.3

1 Answer 1

1

Change the following code:

->addTo([$data['email']])

To

->addTo($data['email'], 'Name')
1
  • I did this above change in my code, but still getting the same error. Can you please help here? Jan 4, 2022 at 6:10

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.