2

I ran across an old thread on how to disable sending of newsletter emails, but it was for Magento 1.9.

How can we disable sending of newsletter emails in Magento2?

6

We can do this in Magento2 using Plugins (Interceptors)

In di.xml of a custom plugin

<type name="Magento\Newsletter\Model\Subscriber">
    <plugin name="my-subscriber" type="MyNamespace\MyModule\Newsletter\Model\Subscriber" sortOrder="1" disabled="1" />
</type>

Then your Interceptor class which wraps the underlying Subscriber instance and turns all sending methods into no-ops

namespace MyNamespace\MyModule\Newsletter\Model;

use Magento\Newsletter\Model\Subscriber as MageSubscriber;

/**
 * Don't send any newsletter-related emails.
 * These will all go out through our marketing platform.
 */
class Subscriber
{
    public function aroundSendConfirmationRequestEmail(MageSubscriber $oSubject, callable $proceed)
    {
        return $oSubject;
    }
    public function aroundSendConfirmationSuccessEmail(MageSubscriber $oSubject, callable $proceed)
    {
        return $oSubject;
    }
    public function aroundSendUnsubscriptionEmail(MageSubscriber $oSubject, callable $proceed)
    {
        return $oSubject;
    }
}

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.