嗨,我写了下面的代码,它将发送一封电子邮件,一切正常,除了它不发送密件抄送外,我不确定是什么导致它不添加密件抄送。任何帮助表示赞赏。
public function sendFraudEmail($observer)
{
/* @var $mailTemplate Mage_Core_Model_Email_Template */
$mailTemplate = Mage::getModel('core/email_template');
$template = Mage::getStoreConfig('sales_email/order/template', Mage::app()->getStore()->getId());
$template_collection = $mailTemplate->load($template);
$template_data = $template_collection->getData();
$templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE);
$mailSubject = $template_data['template_subject'];
$sender = array(
'name' => Mage::getStoreConfig('trans_email/ident_support/name', Mage::app()->getStore()->getId()),
'email' => Mage::getStoreConfig('trans_email/ident_support/email', Mage::app()->getStore()->getId()));
$obj = $mailTemplate->setReplyTo($sender['email'])->setTemplateSubject($mailSubject);
$vars = NULL;
$order = $observer->getEvent()->getOrder();
$storeId = $order->getStoreId();
$IncrementId = $order->getIncrementId();
$status = $order->getStatus();
$customer_name = $order->getCustomerName();
$customer_email = $order->getCustomerEmail();
/*ADD BCC*/
$copyTo = explode(",",Mage::getStoreConfig(self::XML_PATH_EMAIL_BCC));
if (!empty($copyTo) && isset($copyTo)) {
// Add bcc to customer email
foreach ($copyTo as $bccemail) {
$mailTemplate->addBcc($bccemail);
}
}try{
$obj->sendTransactional($templateId, $sender, $customer_email,customer_name, $vars, $storeId);
} catch (exception $e){
Mage::log("something went wrong.." . $e->getMessage());
}