2014-04-15 146 views
1

我试图发送一个确认电子邮件时,在magento中创建订购订单,但不发送任何东西。 我知道电子邮件配置的罚款,因为当我买了一个普通的产品,我收到电子邮件。 我创建了一个模板上System -> Transactional Emails,模板,id=12,然后在代码上class AW_Sarp2_Model_Checkout_Type_Onepage extends Mage_Checkout_Model_Type_Onepage我叫派潜艇电子邮件的方法,但它永远不会发送任何电子邮件发送交易电子邮件magento

class AW_Sarp2_Model_Checkout_Type_Onepage extends Mage_Checkout_Model_Type_Onepage 
{ 
public function saveOrder() 
{ Mage::log("checkout/onepage",null,"onepageemail.log"); 
    $isQuoteHasSubscriptionProduct = Mage::helper('aw_sarp2/quote')->isQuoteHasSubscriptionProduct(
     $this->getQuote() 
    ); 
    if (!$isQuoteHasSubscriptionProduct) //HERE I ASK IF IS A SUBSCRIBE PRODUCT {Mage::log("checkout/onepage34",null,"onepageemail.log"); 
     return parent::saveOrder(); 
    } 
    $this->validate(); 
    $isNewCustomer = false; 
    switch ($this->getCheckoutMethod()) { 
     case self::METHOD_GUEST:Mage::log("checkout/onepage40",null,"onepageemail.log"); 
      $this->_prepareGuestQuote(); 
      break; 
     case self::METHOD_REGISTER:Mage::log("checkout/onepage43",null,"onepageemail.log"); 
      $this->_prepareNewCustomerQuote(); 
      $isNewCustomer = true; 
      break; 
     default:Mage::log("checkout/onepage47",null,"onepageemail.log"); 
      $this->_prepareCustomerQuote(); 
      break; 
    } 

    if ($this->getQuote()->getCustomerId()) {Mage::log("checkout/onepage52",null,"onepageemail.log"); 
     $this->getQuote()->getCustomer()->save(); 
    } 
    #AW_SARP2 override start 
    $service = Mage::getModel('aw_sarp2/sales_service_profile', $this->getQuote());Mage::log("checkout/onepage56",null,"onepageemail.log"); 
    $service->submitProfile();Mage::log("checkout/onepage57",null,"onepageemail.log"); 
    #AW_SARP2 override end 

    $this->getQuote()->save();Mage::log("checkout/onepage60",null,"onepageemail.log"); 
    if ($isNewCustomer) {Mage::log("checkout/onepage61",null,"onepageemail.log"); 
     try { 
      $this->_involveNewCustomer();Mage::log("checkout/onepage63",null,"onepageemail.log"); 
     } catch (Exception $e) { 
      Mage::logException($e); 
     } 
    } 

    $this->_checkoutSession->setLastQuoteId($this->getQuote()->getId()) 
     ->setLastSuccessQuoteId($this->getQuote()->getId()) 
     ->clearHelperData();Mage::log("checkout/onepage71",null,"onepageemail.log"); 
    // add recurring profiles information to the session 
    $profiles = $service->getRecurringPaymentProfiles();Mage::log("checkout/onepage73",null,"onepageemail.log"); 
    if ($profiles) {Mage::log("checkout/onepage74",null,"onepageemail.log"); 
     $ids = array(); 
     foreach ($profiles as $profile) { 
      $ids[] = $profile->getId(); 
     }Mage::log("checkout/onepage78",null,"onepageemail.log"); 
     $this->sendSubscribeEmail2();Mage::log("checkout/onepage79",null,"onepageemail.log"); 

     $this->_checkoutSession->setLastRecurringProfileIds($ids); 
     Mage::log("checkout/onepage82",null,"onepageemail.log"); 
    } 
    return $this; 
} 

public function sendSubscribeEmail2(){ //HERE I TRY TO SEND THE EMAIL 

    $templateId = 12; 
    // 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 = '[email protected]'; 
    $recepientName = 'Test Test'; 
    // Get Store ID 
    $storeId = Mage::app()->getStore()->getId(); 
    // Set variables that can be used in email template 
    $vars = array('customerName' => 'test', 
    'customerEmail' => '[email protected]'); 
    $translate = Mage::getSingleton('core/translate');Mage::log("checkout/onepage103",null,"onepageemail.log"); 
    // Send Transactional Email 
    Mage::getModel('core/email_template') 
    ->sendTransactional($templateId, $sender, $recepientEmail, $recepientName, $vars, $storeId);Mage::log("checkout/onepage106",null,"onepageemail.log"); 
    if (!Mage::getModel('core/email_template')->getSentSuccess()) { 
     Mage::log("EXCEPTION!!!! =(checkout/onepage107",null,"onepageemail.log"); 
    } 

是有什么在xml文件,我必须做其他请帮助我

回答

0

因为我正在处理订阅产品,他们由不同的SMTP提供商处理,在exception.log我得到和错误“曼德勒不能发送电子邮件”类似的东西,然后我去管理面板并在系统下>交易电子邮件有一个名为mandril的子选项卡,我配置该工具,并在mandril,然后创建一个帐户ip将由心轴指示的API密钥放入系统>配置>心轴(左侧)。