无法测试GMail自定义操作 [英] Unable to test the GMail custom actions

查看:105
本文介绍了无法测试GMail自定义操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图测试 GMail行动几天,但它没有似乎工作。由于我没有注册,我使用下面的一小段Java代码,使用GMail的smtp服务器向我自己发送一封电子邮件。消息的正文是文档中的直接副本。

I have been trying to test GMail actions for a few days but it does not seem to work. Since I am not registered I use the little piece of Java code below to send an email from myself to myself using GMail's smtp servers. The message's body is a direct copy from the documentation.

但是,应用程序脚本版本可以正常工作。

The Apps Script version works, though.

final String username = "david.hatanian@gmail.com";
final String password = "X";

Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.port", "587");

Session session = Session.getInstance(props,
        new javax.mail.Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(username, password);
            }
        });

try {

    Message message = new MimeMessage(session);
    message.setFrom(new InternetAddress(username));
    message.setRecipients(Message.RecipientType.TO,
            InternetAddress.parse(username));
    message.setSubject("Testing Subject");
    message.setContent("<html>" +
            "  <head>" +
            "    <script type=\"application/ld+json\">" +
            "    {" +
            "      \"@context\": \"http://schema.org\"," +
            "      \"@type\": \"EmailMessage\"," +
            "      \"description\": \"Check this out\"," +
            "      \"action\": {" +
            "        \"@type\": \"ViewAction\"," +
            "        \"url\":   \"https://www.youtube.com/watch?v=eH8KwfdkSqU\"" +
            "      }" +
            "    }" +
            "    </script>" +
            "  </head>" +
            "  <body>" +
            "    <p>" +
            "      This a test for a Go-To action in Gmail." +
            "    </p>" +
            "  </body>" +
            "</html>", "text/html; charset=utf-8");

    Transport.send(message);

    System.out.println("Done");

} catch (MessagingException e) {
    throw new RuntimeException(e);
}


推荐答案

即使是测试电子邮件也需要使用DKIM / SPF签名以防止欺骗,我不确定是否有办法使用SMTP。

Even test emails need to be signed with DKIM/SPF in order to prevent spoofing, and I'm not sure if there's a way to do that with SMTP.

如果您不想使用Apps Script,一个Google Apps域(具有适当的DKIM / SPF配置)可能是您最好的选择。

If you don't want to use Apps Script, a Google Apps domain (with proper DKIM/SPF configuration) is probably your best bet.

这篇关于无法测试GMail自定义操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆