在magento订单确认电子邮件以HTML格式发送给管理员, 但我想将其更改为纯文本格式,以便我可以如何以及从何处更改该格式仅适用于管理员,客户应该以HTMl格式获取电子邮件。
有人可以给我解决方案吗?
感谢。
答案 0 :(得分:2)
对于未来的读者,不要像其他人建议的那样编辑核心文件。您可以使用 tiny 自定义模块在配置中实现此目的。
我有AheadWorks'安装了博客模块,您可能没有,或者您可能有其他需要覆盖其电子邮件格式的模块。所以,相应调整。
创建app/etc/modules/YourNameSpace_EmailFormat.xml
并添加到<depends>
,以便最后加载您的配置:
<?xml version="1.0"?>
<config>
<modules>
<YourNameSpace_EmailFormat>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Contacts/>
<AW_Blog/>
</depends>
</YourNameSpace_EmailFormat>
</modules>
</config>
创建app/code/local/YourNameSpace/EmailFormat/etc/config.xml
,为您要覆盖的所有模板添加元素:
<?xml version="1.0"?>
<config>
<modules>
<YourNameSpace_EmailFormat>
<version>1</version>
</YourNameSpace_EmailFormat>
</modules>
<global>
<template>
<email>
<customer_create_account_email_template>
<type>text</type>
</customer_create_account_email_template>
</email>
</template>
</global>
</config>
那就是它。我需要反过来,所以我将<type>
设置为html
。这与Yireo's Email Override module非常吻合,因此您可以轻松自定义模板。如果将纯文本电子邮件转换为HTML,请务必将{{var foo.bar}}
之类的模板标记更改为{{htmlescape var=$foo.bar}}
,以防止恶意代码注入。
答案 1 :(得分:0)
你必须覆盖并扩展Mage_Core_Model_Email_Template
模型才能实现这一点,并从那里设置正确的标题,你不能将它们与用户分开,你要为它构建自己的逻辑
答案 2 :(得分:0)
首先从Transactions emails
创建自定义电子邮件模板,将文本类型设置为plain。记下该模板ID。并在下面的文件中使用。
在\app\code\local\Mage\Sales\Model\Order.php
sendNewOrderEmail()
加载手动模板并将变量发送到该模板并发送电子邮件。