1

I'm in a process of integrating Magento 2 with email marketing, i want to stop some of the Magento 2 emails and use the email marketing instead. For example customer registration success, newsletter subscription success, and many others. Instead of creating a plugin or observer for each action, i just need one observer or plugin that can read the email template id and the email data, then stop the email from getting send. Is there a way to this?

0

the model Magento\Email\Model\Transport and the function public function sendMessage() within this model is the deepest part where you can stop and reroute the email.

However, at this point you don't have anymore access to the Magento template identifier that is used. So, if you do need to interact with Magento data, I believe your next fallback is to customise the transportBuilder \Magento\Framework\Mail\Template\TransportBuilder

I have to warn you this area of Magento is quite deep and coupled so there is no straight answer unless we have a thorough understanding of what exactly you are trying to achieve

2
  • is it possible to assign the template identifier and parameter using Magento 2 registry \Magento\Framework\Mail\Template\TransportBuilder ? and then call the registry in Magento\Email\Model\Transport ?
    – jojo
    May 13 '20 at 9:58
  • to get started, you might want to write a plugin on this function \Magento\Framework\Mail\Template\TransportBuilder::setTemplateIdentifier and use the registry here why not.. This may work without needing to touch the Transport model. However, it is likely you will have limitations with the variables in your template.. May 13 '20 at 10:08

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.