I need to modify the welcome email sent to user upon new account creation. I need to do this in my custom module. I tried to override the function sendNewAccountEmail in Magento\Customer\Model\Customer using preference method and also using plugin method. Both were not working.

For preference method I added the following

In Vendor/Module/etc/di.xml

Added Customer.php file in the location Vendor\Module\Model\Customer and added the following code

public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0')
echo "It's Working";exit;
$types = $this->getTemplateTypes();

if (!isset($types[$type])) {
    throw new \Magento\Framework\Exception\LocalizedException(
        __('Please correct the transactional account email type.')

if (!$storeId) {
    $storeId = $this->_getWebsiteStoreId($this->getSendemailStoreId());

    ['customer' => $this, 'back_url' => $backUrl, 'store' => $this->getStore()],

return $this;

Still it's not taking the Customer.php file in the module.

echo "It's Working"; is not displaying.

Please advise the correct method to follow. I tried the plugin method also. It's also not working.

  • You can try Admin Panel Email template setting from Marketing ->Email Template -> Add New Template – Pritam Info 24 Jan 4 at 10:03
  • @Pritam I need to override email template in my custom module not in admin area.. – DEEPESH KUMAR R Jan 4 at 10:07
  • Can you use your custom (assume you using a custom theme ) them instead of any custom module for this customization task? – Pritam Info 24 Jan 4 at 10:41
  • @PritamInfo24 Actually this is custom module, sorry its not possible to use custom theme.. – DEEPESH KUMAR R Jan 4 at 10:45

Your Answer

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

Browse other questions tagged or ask your own question.