Hi,
I'm sending an custom email from the order view page. Basically I am calling a controller (which is based on the frontside - should it be made on admin side instead?), which sends an email and then redirects back to order view page where should show a success message. Everything is working except this message part.
I've checked countless threads and I can't figure out what I'm doing wrong.
Any help appreciated please.
Code below:
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
try{
$this->messageManager->addSuccessMessage(__('Shipping Email sent successfully'));
}catch (\Exception $e) {
$this->messageManager->addErrorMessage($e->getMessage());
}
$resultRedirect->setUrl($this->_redirect->getRefererUrl());
return $resultRedirect;
Solved! Go to Solution.
You just need to create a controller from the backend side and send mail from that!
You just need to create a controller from the backend side and send mail from that!
HI, I tried that but I always get the secret key invalid error. Is there a better way to generate the key than $this->_backendUrl->getSecretKey? I saw some posts in which there's no key generated, just the url via $this->_backendUrl->getRouteUrl and it's supposed to work.
However, both get me to the same error. And I don't want to disable the key for security reasons.
Any advice on this?
Thanks
Thanks, I managed to do the controller from admin and and it solved the message issue as well.