无法在magento 1.9.2社区版中使用自定义模板发送电子邮件

wd2eg0qa  于 2022-11-12  发布在  其他
关注(0)|答案(2)|浏览(137)

我正在尝试使用自定义电子邮件模板在Magento中发送电子邮件。但是我遇到了一个例外。我已经安装了SMTP Pro扩展。
我在这里列出代码:
我的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.

后端电子邮件设置

hkmswyz6

hkmswyz61#

使用此模板

<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>
vsikbqxv

vsikbqxv2#

解决了相同的例外,改变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; }

相关问题