周末我一直在玩 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 调用。如果我查看日志,则没有错误(但我看不到那里的日志......)。
似乎很奇怪,我基本上被收取了发送此邮件的费用(配额已用完),但实际上没有邮件通过。
顺便说一句,我检查了我的垃圾邮件文件夹。