0

周末我一直在玩 Google App Engine 和 Google Web Toolkit,相处得很好,构建了一个简单的应用程序。

绊脚石似乎是发送电子邮件。我的代码是:

private void sendOffenderMail( OffenceDetails offence )
{
    if( offence.email == null || offence.email.equals("") )
    {
        return;
    }

    Properties props = new Properties();
    Session session = Session.getDefaultInstance(props, null);

    String msgBody = "You have been added to the list";

    if( offence.notes != null && !offence.notes.equals( "" ) )
    {
        msgBody += "\n\nThe following notes were included:\n\n" + offence.notes;
    }

    Message msg = new MimeMessage(session);

    try {

        msg.setFrom( new InternetAddress(<gmail account belonging to project viewer>, "List Admin") );
        msg.addRecipient(
                Message.RecipientType.TO,
                new InternetAddress (offence.email, offence.name )
                );
        msg.setSubject("You've been added to the list...");
        msg.setText(msgBody);
        Transport.send(msg);

    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (MessagingException e) {
        e.printStackTrace();
    }
}

当我在开发服务器上运行此日志时,会在控制台中打印出有关将要发送的邮件的日志。当我部署到应用程序引擎并尝试没有任何反应时,我没有收到任何邮件。

如果我查看配额详细信息,我可以在那里看到邮件 api 调用。如果我查看日志,则没有错误(但我看不到那里的日志......)。

似乎很奇怪,我基本上被收取了发送此邮件的费用(配额已用完),但实际上没有邮件通​​过。

顺便说一句,我检查了我的垃圾邮件文件夹。

4

2 回答 2

3

您使用的 gmail 帐户似乎是 Project Viewer。文档声明它应该是开发人员。

于 2013-02-17T20:03:33.617 回答
0

最后,我只使用了当前登录用户的电子邮件地址——它始终是管理员,因为如果您是管理员,您只能访问应用程序的这一部分。我无法使用属于其中一位管理员的硬连线地址使其工作。

于 2013-02-19T13:19:56.423 回答