首页 > 代码库 > java 发送 Email

java 发送 Email

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("baichuanyu@163.com", "bai123yu"));
email.setSSLOnConnect(false);
email.setFrom("baichuanyu@163.com");
email.setSubject("密码找回");
email.setHtmlMsg(context);
email.addTo(mail);
email.send();
} catch (Exception e) {
e.printStackTrace();
}
}