How to add Bcc and Cc to mail that sent by 'core/email_template' model send()
-
12-12-2019 - |
Question
I am sending mail by following code,
$template = Mage::getModel('core/email_template')->loadDefault('customer_email');
$template->addSenderName("MyName");
$template->addSenderEMail("myname@gmail.com");
$template->send("tomail@some.com","toname",$data);
Can i add Bcc and Cc to this $template.if yes or no how it can be?
Solution
Use the ->addBcc()
on the template object to set the bcc recipient. There isn't an equivalent cc method, you instead can pass an array for the email addresses and an array for the names to the ->send()
method:
$template = Mage::getModel('core/email_template')->loadDefault('customer_email');
$template->addSenderName("MyName");
$template->addSenderEMail("myname@gmail.com");
$template->addBcc("some@email.com");
$template->send(array("tomail@some.com","someother@email.com"),array("toname",$othername),$data);
OTHER TIPS
You can add cc and bcc in your email using the following piece of code
$template = Mage::getModel('core/email_template')->loadDefault('email_template_identifier');
$template->getMail()->addCc('your.cc.email@example.com');
$template->addBcc('your.bcc.email@example.com');
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange