使用 JavaMail 的电子邮件通知
我正在尝试一种使用JavaMail实现电子邮件通知的方法。我编写了代码,没有错误。但没有发送任何电子邮件。 我将 GAE 与 JSF2 结合使用。
Properties props = new Properties();
javax.mail.Session session1 = javax.mail.Session.getDefaultInstance(props, null);
String msgBody = "This is a test mail";
try {
System.out.println("Email notification is sending");
Message msg = new MimeMessage(session1);
msg.setFrom(new InternetAddress("[email protected]", "Example.com Admin"));
msg.addRecipient(Message.RecipientType.TO,
new InternetAddress("[email protected]", "Mr. User"));
msg.setSubject("Your Example.com account has been activated");
msg.setText(msgBody);
Transport.send(msg);
System.out.println("Email notification has been sent");
} catch (AddressException e) {
// ...
} catch (MessagingException e) {
// ...
}
我哪里出错了?
I was trying a method to implement email notification Using JavaMail.I wrote the code and there is no error. But no email has been sent.
I am using GAE with JSF2.
Properties props = new Properties();
javax.mail.Session session1 = javax.mail.Session.getDefaultInstance(props, null);
String msgBody = "This is a test mail";
try {
System.out.println("Email notification is sending");
Message msg = new MimeMessage(session1);
msg.setFrom(new InternetAddress("[email protected]", "Example.com Admin"));
msg.addRecipient(Message.RecipientType.TO,
new InternetAddress("[email protected]", "Mr. User"));
msg.setSubject("Your Example.com account has been activated");
msg.setText(msgBody);
Transport.send(msg);
System.out.println("Email notification has been sent");
} catch (AddressException e) {
// ...
} catch (MessagingException e) {
// ...
}
Where I went wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查您的发件人电子邮件地址是否注册为应用程序管理员,或者是登录应用程序的当前用户的电子邮件地址。
根据 App Engine Mail API 文档:
Check that your sender e-mail address either registered as the administrator of your app, or the e-mail address of the current user that's logged in to the app.
According to the App Engine Mail API documentation: