简体   繁体   English

我可以将脚本标签添加到 sendGrid 模板吗?

[英]Can I add script tags to sendGrid templates?

I am trying to add the following script to a sendgrid template我正在尝试将以下脚本添加到 sendgrid 模板

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "EmailMessage",
  "potentialAction": {
    "@type": "ViewAction",
    "target": "https://watch-movies.com/watch?movieId=abc123",
    "name": "Watch movie"
  },
  "description": "Watch the 'Avengers' movie online"
}
</script>

On saving the sendgrid template, it shows saved successfully, but on actually it is not getting saved on refresh.在保存 sendgrid 模板时,它显示已成功保存,但实际上它在刷新时并未保存。 I am guessing sendgrid does not allow to add scripts to email.我猜 sendgrid 不允许向 email 添加脚本。 My purpose is to add gmail actions ( see https://developers.google.com/gmail/markup/reference/go-to-action )我的目的是添加 gmail 操作(请参阅https://developers.google.com/gmail/markup/reference/go-to-action

Edit: Read the Google gmail documentation again. 编辑:再次阅读Google Gmail文档 My guess is that Sendgrid may be removing script tags for security reasons, so you can use div tags instead, in combination with my advice below. 我的猜测是,出于安全原因,Sendgrid可能正在删除脚本标记,因此您可以使用div标记,并结合我的建议。

<div itemscope itemtype="http://schema.org/EmailMessage">
  <div itemprop="potentialAction" itemscope itemtype="http://schema.org/ViewAction">
    <link itemprop="target" href="https://watch-movies.com/watch?movieId=abc123"/>
    <meta itemprop="name" content="Watch movie"/>
  </div>
  <meta itemprop="description" content="Watch the 'Avengers' movie online"/>
</div>

I'm currently facing a similar challenge on adding call-to-actions for gmail via sendgrid. 我目前正面临着通过sendgrid为gmail添加号召性用语的类似挑战。

I think there are 3 different options: 我认为有3种不同的选择:

First, if you want to add custom html you may need to import it as a module . 首先,如果要添加自定义html,可能需要将其作为模块导入 Here are some examples . 这是一些例子

Here are two other potential solutions: 这是另外两个可能的解决方案:

  1. Create a new template using The Code Editor 使用代码编辑器创建新模板
  2. Import the previous template you created using The Design Editor 导入使用“设计编辑器”创建的上一个模板
  3. Add the schema script snippet to your template in The Code Editor 在代码编辑器中将架构脚本片段添加到模板

You can also try editing the HTML head . 您也可以尝试编辑HTML头

The most email client does not support javascript due to security concerns.出于安全考虑,大多数 email 客户端不支持 javascript。 Any good mail client will not support executable code within an email.任何好的邮件客户端都不支持 email 中的可执行代码。 Most email clients remove or disable JavaScript in order to prevent malicious code execution or other security issues.大多数 email 客户端删除或禁用 JavaScript 以防止恶意代码执行或其他安全问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM