How to Disable Welcome Email After Creating New Customer From Admin in Magento 2
A welcome email is the first impression of the Ecommerce store that a company makes with a new customer, blog subscriber, or newsletter subscriber via email.
Magento 2 provides this facility to send a welcome email to newly registered customers. Along with that, it also sends a welcome email if the admin adds a new customer from the admin panel!
But there may be a situation where you would not want to send a welcome email to the customers!
For instance, your store is converting to Magento 2 CMS from any other CMS platform. In that case, you can’t tell your customers to register again in the same store, and so the admin has to create those customers from the backend. It will impact badly if the customer gets a welcome email again.
Or if you are using a third-party customer management system that sends a welcome email already, you would want to skip the default welcome email sent by Magento. Also, in the case of using a custom template for the welcome email, it is only wise to disable the default Magento 2 welcome email that is sent on creating a new account in the store.
In such cases, he would want to disable the welcome email after creating new account from admin in Magento 2.
In all such scenarios, use the below programmatic solution and disable welcome email after creating a new customer from admin in Magento 2 store.
Method to Disable Welcome Email After Creating New Customer From Admin in Magento 2
-
- Use the below code in the di.xml file at app/code/Vendor/Extension/etc/adminhtml
123456789<?xml version="1.0" encoding="utf-8"?><config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"><type name="\Magento\Customer\Model\EmailNotification"><plugin name="disable-email-notification" type="Vendor\Extension\Plugin\EmailNotification" sortOrder="1"/></type></config> - Use the below code in the EmailNotification.php file at app/code/Vendor/Extension/Plugin
12345678910<?phpnamespace Vendor\Extension\Plugin;class EmailNotification{public function aroundNewAccount(\Magento\Customer\Model\EmailNotification $subject, \Closure $proceed){return $subject;}}
- Use the below code in the di.xml file at app/code/Vendor/Extension/etc/adminhtml
We have to use the di.xml file located in the adminhtml because email should be disabled if the admin creates a customer from the admin side.
That’s it.
Any doubts regarding this post? If yes, do mention them in the Comments section below. I’d be happy to help.
Also, do share the post with Magento Community via social media.
Thank you.
Sanjay Jethva
Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe.
His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.
6 Comments
it is disabling all email but instead of this i want to send custom email through observer?
Hey Vishva,
You have to use plugin for that, to disable welcome email.
This code works fine for disable welcome email.
Hi Sanjay !
how can i make this switchable from admin configuration ?
Hello Rejith,
You can create store configuration and get that value in plugin.
Thank You
Code in placee, Magento 2.4. Did not work. Any ideas to determine what happened/how to fix?
Hello Mike,
The code already works in Magento 2.4.
Thank You