4

In Magento 2 how to disable newsletter subscription success email.

Newsletter subscribers after providing email address the address to added to mail newsletter management provider and they will verify the email address.

so i do not want to send any welcome or thank email from magento store.

how to stop sending the thank you for subscription email to subscribers?

1 Answer 1

9

Magento doesn’t have default functionality to stop sending newsletter emails.

Below I show an example of how to disable newsletter subscription emails.

Create a custom module and add di.xml

Override Subscriber.php

app/code/Vendor/Module/etc/di.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Newsletter\Model\Subscriber">
        <plugin name="myplugin" type="Vendor\Module\Newsletter\Model\Subscriber" sortOrder="1" disabled="false"/>
    </type>
</config>

Now create Subscriber.php

app/code/Vendor/Module/Newsletter\Model\Subscriber.php

<?php
 
namespace Vendor\Module\Newsletter\Model;
 
use Magento\Newsletter\Model\Subscriber as SubscriberModel;
 
class Subscriber
{
    /**
     * @param SubscriberModel $subject
     * @param callable $proceed
     */
    public function aroundSendConfirmationRequestEmail(SubscriberModel $subject, callable $proceed) {}
 
    /**
     * @param SubscriberModel $subject
     * @param callable $proceed
     */
    public function aroundSendConfirmationSuccessEmail(SubscriberModel $subject, callable $proceed) {}
 
    /**
     * @param SubscriberModel $subject
     * @param callable $proceed
     */
    public function aroundSendUnsubscriptionEmail(SubscriberModel $subject, callable $proceed) {}
}

Now run following commands

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento cache:clean

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