2014-02-28 74 views
0

我無法使用我的自定義電子郵件模板發送郵件。無法在magento自定義模塊中發送交易電子郵件

我等/ config文件代碼

<template> 
     <email> 
      <quickrfq_email_enquiryadmintemplate translate="label" module="quickrfq"> 
       <label>Admin Enquiery Form</label> 
        <file>enquiryadmin.html</file> 
        <type>html</type> 
      </quickrfq_email_enquiryadmintemplate> 
    </email> 
</template> 

我的控制器代碼發送郵件

  $mailTemplate = Mage::getModel('core/email_template'); 
      /* @var $mailTemplate Mage_Core_Model_Email_Template */ 
      $mailTemplate->setDesignConfig(array('area' => 'frontend')) 
       ->setReplyTo(Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT)) 
       ->sendTransactional(
        Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE), 
        Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER), 
        Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT), 
        null,    
        null 
       ); 

      if (!$mailTemplate->getSentSuccess()) { 
       throw new Exception(); 
      } 

但我爲得到錯誤There has been an error processing your request

+0

var/log中提到的錯誤是什麼? – Slimshadddyyy

+0

異常'帶'消息'這封信不能發送。 – Zaheerabbas

回答

0

試試這個:

$mailTemplate = Mage::getModel('core/email_template'); 
       $mailTemplate->setDesignConfig(array('area' => 'frontend')) 
        ->setReplyTo($post['email']) 
        ->sendTransactional(
         Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE), 
         Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER), 
         Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT), 
         null, 
         array('data' => $postObject) 
        ); 

       if (!$mailTemplate->getSentSuccess()) { 
        throw new Exception(); 
       } 

       $translate->setTranslateInline(true); 

       Mage::getSingleton('customer/session')->addSuccess(Mage::helper('customcontacts')->__('Thanks for your enquiry. We will be in touch shortly!')); 
       $this->_redirect('*/*/'); 

       return; 
0

章將您的控制器代碼改爲:

$mailTemplate = Mage::getModel('core/email_template')->loadDefault('quickrfq_email_enquiryadmintemplate'); 

      $mailTemplate->setDesignConfig(array('area' => 'frontend')) 
       ->setReplyTo(Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT)) 
       ->sendTransactional(
        Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE), 
        Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER), 
        Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT), 
        null,    
        null 
       ); 

      if (!$mailTemplate->getSentSuccess()) { 
       throw new Exception(); 
      } 
相關問題