2
JavaMailを使用して電子メール通知を実装する方法を試していました。コードを書きましたが、エラーはありません。しかし、電子メールは送信されていません。 GAFをJSF2で使用しています。JavaMailを使用した電子メール通知
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) {
// ...
}
どこが間違っていましたか?
ありがとうございました。今それはうまくいっている! –