I’ve edited this function below and i’m overriding this method in app/code/FF/Customer/Model/EmailNotification.php
natively this file exists in vendor/magento/module-customer/Model/EmailNotification.php
/**
* Send corresponding email template
*
* @param CustomerInterface $customer
* @param string $template configuration path of email template
* @param string $sender configuration path of email identity
* @param array $templateParams
* @param int|null $storeId
* @param string $email
* @return void
* @throws MagentoFrameworkExceptionMailException
*/
private function sendEmailTemplate(
$customer,
$template,
$sender,
$templateParams = (),
$storeId = null,
$email = null
) {
$templateId = $this->scopeConfig->getValue($template, 'store', $storeId);
if ($email === null) {
$email = $customer->getEmail();
}
/** @var array $from */
$from = $this->senderResolver->resolve(
$this->scopeConfig->getValue($sender, 'store', $storeId),
$storeId
);
$ccEmail = "$this->scopeConfig->getValue('sales_email/order/copy_to', MagentoStoreModelScopeInterface::SCOPE_STORE);";
$bccEmail = "myemail@gmail.com";
$transport = $this->transportBuilder->setTemplateIdentifier($templateId)
->setTemplateOptions(('area' => 'frontend', 'store' => $storeId))
->setTemplateVars($templateParams)
->setFrom($from)
->addTo($email, $this->customerViewHelper->getCustomerName($customer))
->addCc($ccEmail)
->addBcc($bccEmail)
->getTransport();
$transport->sendMessage();
}
I’ve also created my di.xml file and added this line of code.It resides here: app/code/FF/Customer/etc/di.xml
<preference for="MagentoCustomerModelEmailNotification" type="FFCustomerModelEmailNotification"/>
I’m not sure if there is something i’m still missing but I can’t get it to CC or BCC. It sends the welcome email fine like usual but my code is not working.
I can’t use a plugin because it’s a private method, right? I’m stuck and need some help.