无法获取gmail一键确认操作按钮正常工作

时间:2013-09-06 06:38:32

标签: javascript gmail schema.org google-schemas

我遵循此处所述的指南 https://developers.google.com/gmail/schemas/reference/one-click-action

但它不会出现在我身上。如上所述here

  

自我测试

     

您可以轻松地测试您的标记是否正常端到端地运行   将包含架构的电子邮件发送到您的Gmail帐户。所有电子邮件在哪里   发件人和收件人是同一个帐户忽略的   注册要求,可用于自我测试。

我在地址中使用相同的gmail地址,如下所示

GradeCard gc = new GradeCard("105106265", "BTS");
var m = new UserMailer().ConfirmSubscription("Shashwat", "user@email.com", new WatchListEmail() { fullName = "from Model", gc = gc });

Response.Write(m.Body);

var client = new SmtpClient("smtp.gmail.com", 587)
{
    Credentials = new NetworkCredential("user@email.com", "xxxxx"),
    EnableSsl = true
};

client.Send(m);

生成的邮件的HTML就像这样

<!DOCTYPE html>

<html>
<body>
    <div style="width: 600px; margin: auto; font-family: 'Segoe UI';">
        <h1 style="font-weight:lighter; border-bottom:1px solid #808080; padding:5px 0;">example.com</h1>
        <h3 style="font-weight:lighter;">Action Required. Confirm your subscription for EN abc</h3>
        <p>
            Dear <b>abc</b>
        </p>
        <script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "EmailMessage",
  "description": "Action Required. Confirm your subscription for EN 105106265",
  "action": {
    "@type": "ConfirmAction",
    "name": "Add to watchlist",
    "handler": {
      "@type": "HttpActionHandler",
      "url": "http://www.myignou.com?a=1&b=2"
    }
  }
}
</script>

<p>As you requested, We have just added your subscription to the following detailed enrollment number</p>
<p>
    ...
</p>
<p>
    Click <a href="http://www.myignou.com?a=1&b=2">here to confirm</a>
</p>
<div style="margin:10px 0;">
    <p>
        Here is your most recent copy of grade card as on <b>05-09-2013 00:03:37</b><br />
        Changeset ID: xxx
    </p>

    <table style="width: 100%; text-align: center; border-collapse: collapse;">
        ....
    </table>
    <h3 style="font-weight: lighter;">Other previous changes</h3>
        <div style="padding: 10px">
            <h4 style="font-weight: lighter; margin: 0">Updated on 03-09-2013 15:15:20</h4>
            <div>Changeset ID: abc</div>
            <div>
                ...
            </div>
        </div>
        <div style="padding: 10px">
            <h4 style="font-weight: lighter; margin: 0">Updated on 03-09-2013 15:14:21</h4>
            <div>Changeset ID: xxx</div>
            <div>
                ...
            </div>
        </div>
        <div style="padding: 10px">
            <h4 style="font-weight: lighter; margin: 0">Updated on 03-09-2013 15:14:21</h4>
            <div>Changeset ID: abca</div>
            <div>
                ...
            </div>
        </div>
    </div>
        <div style="padding: 10px; margin: 20px 0; background-color: #f2f0f0; font-size: 85%; color: #686868;">
            <b>&copy; 2013 myIGNOU.com</b><br />

        </div>
    </div>
</body>
</html>

2 个答案:

答案 0 :(得分:6)

您必须首先获得Google的批准才能使用。

要做到这一点:

  1. 将经过验证的架构电子邮件发送到特殊的Google电子邮件地址(使用此工具:https://www.google.com/webmasters/markup-tester/u/0/)...然后:

  2. 填写&#34; Gmail架构白名单请求&#34;描述您的网站的表单以及您打算使用一键式操作执行的操作。以下是表格:https://docs.google.com/forms/d/1PA-vjjk3yJF7MLPOVKbIz3MBfhyma2obS8NIZ0JYx8I/viewform?pli=1&fbzx=-1177483801701354615

答案 1 :(得分:3)

如果您检查电子邮件标题,我希望找不到DKIM / SPF签名,即使是自我测试也是如此。如果没有签名,任何人都可以欺骗您的电子邮件地址并向您发送包含操作的不需要的电子邮件。