无法在magento自定义模块中发送交易电子邮件

时间:2014-02-28 07:18:06

标签: magento email magento-1.7 email-templates

我无法使用自定义电子邮件模板发送邮件。

我的etc / 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

2 个答案:

答案 0 :(得分: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;

答案 1 :(得分: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();
            }