【问题标题】:Can't send transactional e-mail in magento custom module无法在 magento 自定义模块中发送交易电子邮件
【发布时间】:2014-02-28 07:18:06
【问题描述】:

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

我的 etc/config 文件代码

<template>
      <email>
           <quickrfq_email_enquiryadmintemplate translate="label" module="quickrfq">
                <label>Admin Enquiry 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

【问题讨论】:

  • var/log 中提到的错误是什么?
  • 异常 'Exception' with message 'This letter cannot be sent.

标签: magento email magento-1.7 email-templates


【解决方案1】:

试试这个:

 $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;

【讨论】:

  • 总是运行失败发送邮件成功
【解决方案2】:

将您的控制器代码更改为以下:

$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();
            }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-31
    • 2014-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-24
    相关资源
    最近更新 更多