如何使用Mailchimp和/或Mandrill从电子邮件标题中删除* | MC_PREVIEW_TEXT | *

问题描述 投票:11回答:9

我创建了一个电子邮件模板,其中包括在MailChimp上合并标签,然后将其发布到Mandrill。

当我的脚本运行并且我收到电子邮件时,如您所见,| MC_PREVIEW_TEXT |出现在标题中。

我在Mandrill和MailChimp上搜索了这个标签,但它没有出现在任何一个模板文件中。

如何从电子邮件中删除此内容?

email mailchimp mandrill
9个回答
7
投票

我遇到了同样的问题,因为我在发送电子邮件时使用了Handlebars作为合并语言。

Mailchimp使用Mailchimp合并语言将MC_PREVIEW_TEXT变量放在模板中,因此如果您使用Handlebars,它会显示出来。

要解决此问题,您必须在Mandrill设置 - >发送默认值中将合并语言设置为句柄。

但是当你这样做时,你必须在Mailchimp中设计电子邮件时使用Mailchimp合并语言,你不能使用Handlebars。

然后当您从Mailchimp发送到Mandrill时,它会将所有合并变量转换为Handlebars。


7
投票

我曾经通过Mandrill模板编辑器这样做。 enter image description here

只需移除身体开口后出现的这些线条:

    <!--*|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>,并将此代码添加到“样式类型”值:

在打开<body>标签之后,添加:enter image description here


4
投票

我们使用两种方法:

  1. 通过Mandrill REST API:在POSTed请求体中使用您的API密钥,点击/templates/info.json端点,替换有问题的标记,然后将修改后的对象转发给/templates/update.json
  2. 通过GUI:Mandrill exposes a GUI修改模板,让您触摸比Mailchimp编辑器更多的代码。只需删除它。

最后我检查过,每次将Mailchimp模板发送到Mandrill时,MC_PREVIEW_TEXT标签都会重新出现。选择最适合您的方法并坚持使用Mandrill来修改Handlebars模板。


1
投票

我们在Mailchimp模板编辑器中遇到了与向Mandrill发送模板相同的问题。还有一个问题是,由于Mailchimp模板编辑器将https://附加到车把标签上,迫使我们从有效负载中的网址中删除https://。因此,为了修复MC_PREVIEW_TEXTand问题,我创建了一个Firefox扩展。

https://addons.mozilla.org/en-US/firefox/addon/mandrillchimp/

您需要做的唯一事情是创建“特殊”Mandrill API密钥,它将允许扩展以获取和更新模板(信息和更新权限)。


1
投票

打开html文件然后ctrl+f,然后使用|MC_PREVIEW_TEXT|搜索并替换你的文本而不是它


1
投票

我们有同样的问题,所以我为我们的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

要使其工作,应该采取以下措施:

  1. 安装Mandrill API客户端作为gemgem install mandrill-api或添加到您的Gemfile:gem 'mandrill-api'
  2. 使用上面列出的代码在lib / tasks /文件夹中创建任何rake任务(例如remove_mc_preview_text.rake)
  3. 将'YOUR_API_KEY'更改为您真正的Mandrill API密钥
  4. templates数组中的模板名称更改为真实模板,如果由于某种原因你不知道它们,你可以在这里找到它们https://mandrillapp.com/templates

最后在rails app的根文件夹中运行此命令:

bundle exec rake mandrill:remove_mc_preview_text

如果您使用任何其他编程语言,您可以使用我的示例编写类似的脚本,请参阅Mandrill API Clients了解不同的编程语言。


0
投票

预览文本是预填充文本,将在填充时显示。根据经验,我看到合并标签出现在测试中。你可以做两件事:

  1. 在数据文件中为预览文本添加文本基本上每个人或每个人都一样
  2. 您可以将其添加到MailChimp中的模板。

如何更改前标题:changing pre header

干杯


0
投票

这可能有助于你们中的一些人想知道如何做到这一点。

从MailChimp导出HTML模板到Intercom时遇到了问题。

行号可能不同,因此将HTML代码复制到记事本/文本编辑和搜索| MC_PREVIEW_TEXT |找到它

Video with instructions


0
投票

从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代码插入邮件正文中。 现在你的问题应该解决了....

© www.soinside.com 2019 - 2024. All rights reserved.