0

send CC to another email前述のコードを使用しようとしていますが、

次のエラーが表示されます。

Varien_Exception Object ( [message:protected] => Invalid method Mage_Core_Model_Email_Template::addCc(Array ( [0] => abc@gmail.com ) ) [string:Exception:private] => [code:protected] => 0 [file:protected] => /var/domains/alldaychemist/lib/Varien/Object.php [line:protected] => 652 [trace:Exception:private] => Array ( [0] => Array ( [file] => /var/domains/alldaychemist/adminuser.php [line] => 59 [function] => __call [class] => Varien_Object [type] => -> [args] => Array ( [0] => addCc [1] => Array ( [0] => abc@gmail.com ) ) ) [1] => Array ( [file] => /var/domains/alldaychemist/adminuser.php [line] => 59 [function] => addCc [class] => Mage_Core_Model_Email_Template [type] => -> [args] => Array ( [0] => abc@gmail.com ) ) ) [previous:Exception:private] => )

以下のコードを使用してメールを送信するたびに、このエラーが発生します。

-Invalid method Mage_Core_Model_Email_Template::addCc

私のコードは次のようになります。

$templateId = 15;

// Set sender information
$senderName = Mage::getStoreConfig('trans_email/ident_support/name');
$senderEmail = Mage::getStoreConfig('trans_email/ident_support/email');
$sender = array('name' => $senderName,
    'email' => $senderEmail);

// Set recepient information
$recepientEmail = 'adcc@gmailcom';
$recepientName = 'John Doe';        

// Get Store ID
$store = Mage::app()->getStore()->getId();

// Set variables that can be used in email template
$vars = array('customerName' => 'customer@example.com',
    'customerEmail' => 'Mr. Nil Cust');

$translate  = Mage::getSingleton('core/translate');

// Send Transactional Email
try{
Mage::getModel('core/email_template')
->addCc('abc@gmail.com')
->addBcc('abcd2@gmail.com')
->sendTransactional($templateId, $sender, $recepientEmail, $recepientName, $vars, $storeId);
}
catch(Exception $e){
    print_r($e);
}   

$translate->setTranslateInline(true);
4

1 に答える 1

3

Unlike addBcc,addCc is not defined in class Mage_Core_Model_Email_Template. You can either extend Mage_Core_Model_Email_Template class to include addCc method in a similar fashion as addBcc, or modify your code like this:

// Send Transactional Email
try{
  $mail = Mage::getModel('core/email_template');
  $mail->getMail()->addCc('abc@gmail.com');  

  $mail->addBcc('abcd2@gmail.com')
  ->sendTransactional($templateId, $sender, $recepientEmail, $recepientName, $vars, $storeId);
}
catch(Exception $e){
    print_r($e);
}  
于 2014-09-12T04:29:59.510 に答える