Jsp java中的电子邮件通知
我正在开发升级跟踪系统。在我的应用程序中,如果某个升级的截止日期临近,我必须发送电子邮件通知(根据某些条件自动发送)。这是一个基于web的应用程序。我正在使用servlet jsp。谁能告诉我怎样才能实现电子邮件通知功能Jsp java中的电子邮件通知,jsp,servlets,Jsp,Servlets,我正在开发升级跟踪系统。在我的应用程序中,如果某个升级的截止日期临近,我必须发送电子邮件通知(根据某些条件自动发送)。这是一个基于web的应用程序。我正在使用servlet jsp。谁能告诉我怎样才能实现电子邮件通知功能 先走一步 您可以使用Java Mail api来实现这一点。请按照代码中的以下步骤发送电子邮件 设置SMTP主机属性 Properties props = System.getProperties(); props.put("mail.smtp.host", yours
先走一步 您可以使用Java Mail api来实现这一点。请按照代码中的以下步骤发送电子邮件
Properties props = System.getProperties();
props.put("mail.smtp.host", yoursmtpServer);
Session session = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to, false));
msg.setSubject(subject);
msg.setText(body);
// -- Set some other header information --
msg.setHeader("X-Mailer", "ABCMail");
msg.setSentDate(new Date());
// -- Send the message --
Transport.send(msg);
- 使用ScheduledThreadPoolExecutor实现计时器
- 通过实现Runnable创建任务
- 把你的逻辑放在你的跑步中
- 时间表(任务,1,时间单位:天)李>