我正在尝试一种使用 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("myGmailId1@gmail.com", "Example.com Admin"));
msg.addRecipient(Message.RecipientType.TO,
new InternetAddress("myGmailId2@gmail.com", "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) {
// ...
}
我哪里出错了?