【问题标题】:Not able to send email using custom template in magento 1.9.2 community edition无法在 magento 1.9.2 社区版中使用自定义模板发送电子邮件
【发布时间】:2016-08-01 11:29:36
【问题描述】:

我正在尝试使用自定义电子邮件模板在 Magento 中发送电子邮件。但我遇到了一个例外。我已经安装了 SMTP Pro Extension。

我在这里列出代码:

我的 config.xml

<template>
  <email>
    <custom_abc_email_template  module="custom_abc">
      <label>Custom Template</label>
      <file>custom_abc_templates/customTemplate.html</file>  // this specifies the path where the custom template is located
      <type>html</type>
    </custom_abc_email_template>
  </email>
</template>

我的控制器操作代码

$emailTemplate  = Mage::getModel('core/email_template')->loadDefault('custom_abc_email_template');
$emailTemplate->setSenderName('custom template');
$emailTemplate->setSenderEmail('abc@demomail.com');
$emailTemplate->send('abc@demomail.com','Forgot Password');

我的模板文件代码

<table cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td class="action-content">
            <h1>Custom Abc,</h1>
            <p><strong>Your new password is:</strong> trolled</p>
            <p>You can change your password at any time by logging into <a href="{{store url="customer/account/"}}">your account</a>.</p>
        </td>
    </tr>
</table>

在异常日志中

2016-04-11T10:03:18+00:00 ERR (3): exception 'Exception' with message
'This letter cannot be sent.' in /var/www/html/MMM/app/code/local/Aschroder/SMTPPro/Model/Email/Template.php:40

在 aschroder_smtppro.log 中

2016-04-11T10:03:18+00:00 DEBUG (7): Email is not valid for sending, 
this is a core error that often means there's a problem with your email templates.

后台邮箱设置

【问题讨论】:

    标签: php magento magento-1.9 email-templates


    【解决方案1】:

    使用这个模板

    <table cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td class="action-content">
            <h1>Custom Abc,</h1>
            <p><strong>Your new password is:</strong> trolled</p>
            <p>You can change your password at any time by logging into <a href="{{store url='customer/account/'}}">your account</a>.</p>
        </td>
    </tr>
    

    【讨论】:

      【解决方案2】:

      通过更改 Magento 系统电子邮件设置解决了相同的异常。 插件的电子邮件模板代码中设置了异常(见下文)。

      在管理员中,从顶部菜单中选择系统 -> 配置,然后转到系统 - 邮件发送设置。将“禁用电子邮件通信”设置为“否”。

      if (!$this->isValidForSend()) {
          $_helper->log('Email is not valid for sending, this is a core error that often means there\'s a problem with your email templates.');
          Mage::logException(new Exception('This letter cannot be sent.')); // translation is intentionally omitted
          return false; }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-03-31
        • 1970-01-01
        • 1970-01-01
        • 2023-03-24
        • 2021-06-29
        • 2014-02-10
        相关资源
        最近更新 更多