我创建了一个电子邮件模板,其中包括在MailChimp上合并标签,然后将其发布到Mandrill。
当我的脚本运行并且我收到电子邮件时,如您所见,| MC_PREVIEW_TEXT |出现在标题中。
我在Mandrill和MailChimp上搜索了这个标签,但它没有出现在任何一个模板文件中。
如何从电子邮件中删除此内容?
我遇到了同样的问题,因为我在发送电子邮件时使用了Handlebars作为合并语言。
Mailchimp使用Mailchimp合并语言将MC_PREVIEW_TEXT变量放在模板中,因此如果您使用Handlebars,它会显示出来。
要解决此问题,您必须在Mandrill设置 - >发送默认值中将合并语言设置为句柄。
但是当你这样做时,你必须在Mailchimp中设计电子邮件时使用Mailchimp合并语言,你不能使用Handlebars。
然后当您从Mailchimp发送到Mandrill时,它会将所有合并变量转换为Handlebars。
只需移除身体开口后出现的这些线条:
<!--*|IF:MC_PREVIEW_TEXT|*-->
<!--[if !gte mso 9]><!----><span class="mcnPreviewText"
style="display:none; font-size:0px; line-height:0px; max-height:0px; max-width:0px; opacity:0; overflow:hidden; visibility:hidden; mso-hide:all;">*|MC_PREVIEW_TEXT|*</span>
<!--<![endif]-->
<!--*|END:IF|*-->
要了解有关此合并标记的更多信息: https://kb.mailchimp.com/merge-tags/all-the-merge-tags-cheat-sheet
使用此合并标记可在自定义编码的广告系列中生成预览文本。插入| MC_PREVIEW_TEXT |就在HTML中打开<body>标记之后。要确保在广告系列正文中看不到预览文字,请将合并标记包装在隐藏的<span>元素中。
在HTML中找到或添加<style type =“text / css”> </ script>,并将此代码添加到“样式类型”值:
我们使用两种方法:
最后我检查过,每次将Mailchimp模板发送到Mandrill时,MC_PREVIEW_TEXT
标签都会重新出现。选择最适合您的方法并坚持使用Mandrill来修改Handlebars模板。
我们在Mailchimp模板编辑器中遇到了与向Mandrill发送模板相同的问题。还有一个问题是,由于Mailchimp模板编辑器将https://
附加到车把标签上,迫使我们从有效负载中的网址中删除https://
。因此,为了修复MC_PREVIEW_TEXT
and问题,我创建了一个Firefox扩展。
https://addons.mozilla.org/en-US/firefox/addon/mandrillchimp/
您需要做的唯一事情是创建“特殊”Mandrill API密钥,它将允许扩展以获取和更新模板(信息和更新权限)。
打开html文件然后ctrl+f
,然后使用|MC_PREVIEW_TEXT|
搜索并替换你的文本而不是它
我们有同样的问题,所以我为我们的ROR应用程序编写了简单的rake任务,删除了| MC_PREVIEW_TEXT |自动部分来自Mandrill模板。这是我的rake任务的一个例子:
require 'mandrill'
namespace :mandrill do
desc 'Removes *|MC_PREVIEW_TEXT|* section for all email templates in mandrill app'
task remove_mc_preview_text: :environment do
# Templates with handlebars merge language
templates = [
'template-example-1',
'template-example-2',
]
mandrill = Mandrill::API.new 'YOUR_API_KEY'
templates.each do |name|
begin
puts "Processing the template: #{name}"
# Get the information for an existing template
result = mandrill.templates.info name
# Finds the section with MC_PREVIEW_TEXT inside a template and substitutes it to the empty string
code = result['code'].sub(/\<\!\-\-\*\|IF:MC_PREVIEW_TEXT[[:ascii:]]+END:IF\|\*\-\-\>/m, '')
# If nil is provided for any fields, the values will remain unchanged.
from_email = nil
from_name = nil
subject = nil
text = nil
labels = nil
# Set to false to update the draft version of the template without publishing
publish = true
# Update the code for an existing template
mandrill.templates.update name, from_email, from_name, subject, code, text, publish, labels
puts "Successfully deleted *|MC_PREVIEW_TEXT|* section from the template: #{name}"
rescue Mandrill::Error => e
# Mandrill errors are thrown as exceptions
puts "A mandrill error occurred: #{e.class} - #{e.message}"
end
end
puts 'Done!'
end
end
要使其工作,应该采取以下措施:
gem install mandrill-api
或添加到您的Gemfile:gem 'mandrill-api'
templates
数组中的模板名称更改为真实模板,如果由于某种原因你不知道它们,你可以在这里找到它们https://mandrillapp.com/templates最后在rails app的根文件夹中运行此命令:
bundle exec rake mandrill:remove_mc_preview_text
如果您使用任何其他编程语言,您可以使用我的示例编写类似的脚本,请参阅Mandrill API Clients了解不同的编程语言。
这可能有助于你们中的一些人想知道如何做到这一点。
从MailChimp导出HTML模板到Intercom时遇到了问题。
行号可能不同,因此将HTML代码复制到记事本/文本编辑和搜索| MC_PREVIEW_TEXT |找到它
从html代码中删除以下行:
<span class="m_-63420320203924518mcnPreviewText" style="display:none;font-size:0px;line-height:0px;max-height:0px;max-width:0px;opacity:0;overflow:hidden">*|MC_PREVIEW_TEXT|*</span>
在此之后,将html代码插入邮件正文中。 现在你的问题应该解决了....