2

我正在尝试在从 codeigniter 的电子邮件库发送电子邮件时嵌入 gmail操作按钮。我的邮件是这样的——

     $this->email->from('mail@mysite.com', 'MyName');
     $this->email->to('user@yoursite.com');
     $this->email->set_mailtype("html");
     $this->email->subject('Testing action');
     $msg = '<html>
    <body>
    <script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "EmailMessage",
  "action": {
    "@type": "ViewAction",
    "url": "https://watch-movies.com/watch?movieId=abc123"
  },
  "description": "Watch the Avengers movie online"
}
</script>
    <div>EMAIL CONTENT GOES HERE</div>
    </body>
    </html>';
    $this->email->message($message);

在此之后,我正在发送邮件。它只发送<div>EMAIL CONTENT GOES HERE</div>部分。没有生成操作按钮。我什至尝试使用 Google 开发者页面中提供的微数据。没有任何效果。知道这里有什么问题吗?

4

1 回答 1

0

首先,您似乎使用了错误的变量$message而不是$msg.

除此之外,我认为 condeigniter 正在逃避您的代码。看_prep_quoted_printable功能。

我建议你使用微数据方法:https ://developers.google.com/gmail/actions/reference/formats/microdata

从例子:

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

另外,不要忘记您必须向 Google 注册您的操作:http: //developers.google.com/gmail/actions/registering-with-google

于 2013-11-06T22:01:03.527 回答