cancel
Showing results for 
Search instead for 
Did you mean: 

e-mail notification new customer

e-mail notification new customer

hello, if someone registers or i create an account for the customer, he gets an e-mail notification where to put it!

1 REPLY 1

Re: e-mail notification new customer

You may achieve this by following code.

 

app\code\Company\CustomerRegistration\etc\frontend

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="customer_register_success">
        <observer name="sendmail_toadmin" instance="Company\CustomerRegistration\Observer\SendMailToAdmin"/>
    </event>
</config>

Then create an observer.

\app\code\Company\CustomerRegistration\Observer

<?php
declare(strict_types=1);

namespace Company\CustomerRegistration\Observer;

use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Framework\App\Area;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\DataObject;
use Magento\Framework\Escaper;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Mail\Template\TransportBuilder;
use Magento\Framework\Translate\Inline\StateInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\StoreManagerInterface;
use Psr\Log\LoggerInterface;
use Magento\Eav\Model\Config;

class SendMailToAdmin implements ObserverInterface
{

    /** @var TransportBuilder */
    protected $_transportBuilder;

    /** @var StateInterface */
    protected $inlineTranslation;

    /** @var ScopeConfigInterface */
    protected $scopeConfig;

    /** @var StoreManagerInterface */
    protected $storeManager;

    /** @var Escaper */
    protected $_escaper;

    /** @var LoggerInterface */
    private $logger;

    protected $customerRepositoryInterface;

    /* @var Config */
    private $eavConfig;

    public function __construct(
        TransportBuilder $transportBuilder,
        StateInterface $inlineTranslation,
        ScopeConfigInterface $scopeConfig,
        StoreManagerInterface $storeManager,
        Escaper $_escaper,
        LoggerInterface $logger,
        CustomerRepositoryInterface $customerRepositoryInterface,
        Config $eavConfig
    ) {
        $this->_transportBuilder = $transportBuilder;
        $this->inlineTranslation = $inlineTranslation;
        $this->scopeConfig = $scopeConfig;
        $this->storeManager = $storeManager;
        $this->_escaper = $_escaper;
        $this->logger = $logger;
        $this->customerRepositoryInterface = $customerRepositoryInterface;
        $this->eavConfig = $eavConfig;
    }

    /**
     * Send Cc email for customer registration
     *
     * @param Observer $observer
     * @return void
     */
    public function execute(Observer $observer): void
    {
        $customer = $observer->getData('customer');
        // write your logic here

        
    }

}

 

Thanks

---
Problem Solved Click Accept as Solution!:Magento Community India Forum