如何将Gmail操作按钮添加到codeigniter的电子邮件库?

时间:2013-11-06 13:47:22

标签: php codeigniter email gmail

我在尝试从codeigniter的电子邮件库发送电子邮件时嵌入gmail action buttons。我的邮件看起来像这样 -

     $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>部分。没有生成动作按钮。我甚至试过谷歌开发者页面中给出的微数据。什么都行不通。知道这里有什么问题吗?

1 个答案:

答案 0 :(得分: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