private static void sendMail(String mail, String mailContext) {
try {
String context = FileUtil.getFileContent("lostpassEmail.html");
HtmlEmail email = new HtmlEmail();
email.setHostName("smtp.163.com");
email.setSmtpPort(25);
email.setAuthenticator(new DefaultAuthenticator("[email protected]", "bai123yu"));
email.setSSLOnConnect(false);
email.setFrom("[email protected]");
email.setSubject("密码找回");
email.setHtmlMsg(context);
email.addTo(mail);
email.send();
} catch (Exception e) {
e.printStackTrace();
}
}
java 发送 Email
时间: 2024-10-28 11:37:52