2

I have created a transactional email template and sending mail using below code :

$to_user_email = '[email protected]'; $to_user = 'test'; $emailTemplate = Mage::getModel('core/email_template')->loadByCode('My Template'); $senderName = Mage::getStoreConfig('trans_email/ident_support/name'); $senderEmail = Mage::getStoreConfig('trans_email/ident_support/email'); $sender = array('name' => $senderName, 'email' => $senderEmail); $store = Mage::app()->getStore()->getId(); // Set variables that can be used in email template $vars = array(); $vars['order_id'] = 'order_id'; $vars['content'] = 'content'; $processedTemplate = $emailTemplate->getProcessedTemplate($vars); $mail = Mage::getModel('core/email') ->setToName($to_user) ->setToEmail($to_user_email) ->setBody($processedTemplate) ->setSubject('Subject') ->setFromEmail($senderEmail) ->setFromName($senderName) ->setType('TEXT') ->setCc(array('[email protected]','[email protected]')); $mail->send(); 

From above code email sent to $to_user_email but cc not sent to '[email protected]', '[email protected]'.

How to send cc or bcc to multiple email address?

1
  • How to configure mail in magento Commented Jul 22, 2016 at 5:12

2 Answers 2

8

Use below code:

$mail = Mage::getModel('core/email_template'); $mail->getMail()->addCc('[email protected]'); $mail->addBcc('[email protected]') ->setDesignConfig(array('area' => 'frontend', 'store' => $storeId)) ->setTemplateSubject($mailSubject) ->sendTransactional($templateId, $sender, $useremail, $emailName, $vars, $storeId); 
4
  • Hello @Prashant Valanda, where you set My Template transactional email template? Commented Jul 22, 2016 at 5:01
  • Instead of $templateId you need to pass your template Commented Jul 22, 2016 at 5:04
  • I have tried this code but no email sent to $useremail and also not sent to cc/bcc email address. Commented Jul 22, 2016 at 5:24
  • nice to hear it is working for you.If it helps you mark as accepted for further use. Commented Jul 22, 2016 at 5:43
2

Please check below code

 $storeId=Mage::app()->getStore()->getId(); $emailTemplateId='Youe email temlate'; //Multiple BCC email address $add_bcc=array("[email protected]","[email protected]"); //Multiple CC email address $add_cc=array("[email protected]","[email protected]"); $email='[email protected]'; $sender = Array('name' => 'test','email' => '[email protected]'); $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); 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.