public void fun1() throws Exception {
/*
* 1. 得到session
*/
Properties props = new Properties();
props.setProperty("mail.host", "smtp.126.com");
props.setProperty("mail.smtp.auth", "true");
Authenticator auth = new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("lchqqqqq", "lch520.");
}
};
Session session = Session.getInstance(props, auth);
/*
* 2. 创建MimeMessage
*/
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("[email protected]"));//设置发件人
msg.setRecipients(RecipientType.TO, "[email protected]");//设置收件人
msg.setSubject("这是来自ITCAST的测试邮件");
msg.setContent("这就是一封垃圾邮件!", "text/html;charset=utf-8");
/*
* 3. 发
*/
Transport.send(msg);
}
然后出现了下面那个错误,谁能告诉一下!!!
/*
* 1. 得到session
*/
Properties props = new Properties();
props.setProperty("mail.host", "smtp.126.com");
props.setProperty("mail.smtp.auth", "true");
Authenticator auth = new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("lchqqqqq", "lch520.");
}
};
Session session = Session.getInstance(props, auth);
/*
* 2. 创建MimeMessage
*/
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("[email protected]"));//设置发件人
msg.setRecipients(RecipientType.TO, "[email protected]");//设置收件人
msg.setSubject("这是来自ITCAST的测试邮件");
msg.setContent("这就是一封垃圾邮件!", "text/html;charset=utf-8");
/*
* 3. 发
*/
Transport.send(msg);
}
然后出现了下面那个错误,谁能告诉一下!!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货