2014-04-15 186 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密鑰放入系統>配置>心軸(左側)。