How To Set BCC For Customer Welcome Email In Magento?

No comments

TASK

Set BCC for the welcome emails that are sent to the new customers when they register new accounts.

SOLUTIONS

  • The 1st method:

In your custom module

– Rewrite model Mage_Customer_Model_Customer in config.xml

<config>
			<global>
				<models>
					...
					<customer>
						<rewrite>
							<customer>Vendor_Namespace_Model_Customer_Customer</customer>
						</rewrite>
					</customer>
					...
				</models>
			</global>
		</config>

– Create Customer.php in path Vendor/Namespace/Model/Customer/Customer and override function _sendEmailTemplate

class Vendor_Namespace_Model_Customer_Customer extends Mage_Customer_Model_Customer
		{
			...
				protected function _sendEmailTemplate($template, $sender, $templateParams = array(), $storeId = null, $customerEmail = null)
				{
					$customerEmail = ($customerEmail) ? $customerEmail : $this->getEmail();
					/** @var $mailer Mage_Core_Model_Email_Template_Mailer */
					$mailer = Mage::getModel('core/email_template_mailer');
					$emailInfo = Mage::getModel('core/email_info');
					$emailInfo->addTo($customerEmail, $this->getName());
					$mailer->addEmailInfo($emailInfo);

					//add bbc
					$mailer->addBcc('your_email@gmail.com');
					
					// Set all required params and send emails
					$mailer->setSender(Mage::getStoreConfig($sender, $storeId));
					$mailer->setStoreId($storeId);
					$mailer->setTemplateId(Mage::getStoreConfig($template, $storeId));
					$mailer->setTemplateParams($templateParams);
					$mailer->send();
					return $this;
				}
			...
		}
  • The 2nd method:

Add the following code

$storeId=Mage::app()->getStore()->getId();
	$emailTemplateId='Youe email temlate';
	//Multiple BCC email address
	$add_bcc=array("someone@domain.com","someone2@domain.com");
	//Multiple CC email address
	$add_cc=array("someone3@domain.com","someone4@domain.com");
	$email='useremail@domain.com';
	$sender = Array('name' => 'test','email' => 'test@domain.com');
	$mailSubject='Your subject';
	$vars = Array('name' => 'Your message');

	$translate=Mage::getModel('core/email_template');
	$translate->getMail()->addCc($add_cc);
	$translate->setTemplateSubject($mailSubject)
		->addBCC($add_bcc)
		->sendTransactional($emailTemplateId, $sender, $email, null, $vars, $storeId);
	$translate->setTranslateInline(true);

See More Our Magento “How To” Series:

How To Config Sitemap in Magento 2?

How To Use Flat Catalog In Magento 2?

How To Config URL Rewrite in Magento 2?

How To Create New Cart Price Rule In Magento 2

How To Create New Catalog Price Rule In Magento 2

How To Set Up Automatic Product Redirects in Magento 2?

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...
April LeeHow To Set BCC For Customer Welcome Email In Magento?

Related Posts

Leave a Reply