【问题标题】:How to add Gmail action buttons to codeigniter's email library?如何将 Gmail 操作按钮添加到 codeigniter 的电子邮件库?
【发布时间】:2013-11-17 18:57:20
【问题描述】:

我正在尝试在从 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);

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

【问题讨论】:

    标签: php codeigniter email gmail


    【解决方案1】:

    首先,您似乎使用了错误的变量$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

    【讨论】:

    • 另外,别忘了您必须向 Google 注册您的操作:developers.google.com/gmail/actions/registering-with-google
    • $msg 和 $message 只是一种类型。对此感到抱歉。我想我还没有在 Google 上进行任何操作注册。这可能是问题所在。让我试试看。谢谢。
    • 不客气@pnhegde。如果你我回答了你的问题,如果你接受它作为正确答案,我将不胜感激。
    • 嘿@pnhegde,如果我的回答对您有帮助,如果您将其标记为正确,我将不胜感激。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-26
    相关资源
    最近更新 更多