0

I call my email template from my controller and send variables to it so I don't need to rewrite the entire template (header & footer) especially because they might change during time.

So, I'm using this function in my execute() controller :

.....
$transport = $this->_transportBuilder
                ->setTemplateIdentifier(132)
                ->setTemplateOptions(
                    [
                        'area' => 'frontend',
                        'store' => $this->storeManager->getStore()->getId()
                    ]
                )
                ->setTemplateVars([
                    'email' => $email,
                    'result' => $this->resultText(
                        $result_acuity,
                        $result_astigmatism,
                        $result_contrast,
                        $result_vision_lecture,
                        $result_vision_colors,
                        $result_colors,
                        $result_DLMA
                    )
                ])
                ->setFrom($sender)
                ->addTo($email, $name)
                ->addTo($sentToEmail,$sentToName)
                ->getTransport();

            $transport->sendMessage();
....

Inside of it, I call my template with the id number from my BO :

->setTemplateIdentifier(132)

I receive the email correctly except for the media. Those are stored in BO wysiwyg and are correctly displaying when I do the preview temmplate (they are called in the template, not in controller)

Is there something I need to know for it to work ?

1 Answer 1

0

Ok, so I found out that my project needs to be on a server for the immage to be displaying, even if they are stocked in admin backoffice wysiwyg, otherwise, any mail server will block them for security.

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.