Magento 2 How to Send Welcome Email to Customer After Registration

When you create an account from frontend or create an account from admin panel, both the events send mail to a customer after successful creation of an account.
Magento 2 send Welcome email from the Magento/Customer/Model/EmailNotification file.

public function newAccount() used for sending welcome email after a successful registration.

Above function firstly checks whether the email transaction account template is set or not, if email template is not set, it throws error.

You can set custom email template for Welcome email from the,
Stores -> Configuration -> Customers -> Customer Configuration -> Create New Account Options -> Default Welcome Email
Default template is New Account(Default).

If the email transaction template is set, the function will send mail using sendEmailTemplate() function with related information of newly created account.

sendEmailTemplate() is private function defined under EmailNotification class.

If you want to disable send customer welcome email, you can create an around plugin with aroundNewAccount() method with required arguments and return the $subject so your welcome email will be not sent from Magento.

Alternatively, you can also apply preference where can override the newAccount() method and can add your custom code changes not to send email from here or simply call return statement.

As a Magento standard, we should prefer the preference compared to around plugin.

Hope this helps you guys!

Leave a Reply