javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.AuthenticationFailedException
at javax.mail.Transport.send0(Transport.java:218)
at javax.mail.Transport.send(Transport.java:80)
at com.util.mail.SimpleMailSender.sendTextMail(SimpleMailSender.java:33)
at bb.Test.main(Test.java:84)哪位高手知道哪里出了错,先谢
我的调用:
mailInfo.setMailServerHost("smtp.126.com");
mailInfo.setMailServerPort("25");
mailInfo.setValidate(true);
mailInfo.setUserName("**@126.com");
mailInfo.setPassword("******");
mailInfo.setFromAddress("**@126.com");
mailInfo.setToAddress("**@126.com");
nested exception is:
class javax.mail.AuthenticationFailedException
at javax.mail.Transport.send0(Transport.java:218)
at javax.mail.Transport.send(Transport.java:80)
at com.util.mail.SimpleMailSender.sendTextMail(SimpleMailSender.java:33)
at bb.Test.main(Test.java:84)哪位高手知道哪里出了错,先谢
我的调用:
mailInfo.setMailServerHost("smtp.126.com");
mailInfo.setMailServerPort("25");
mailInfo.setValidate(true);
mailInfo.setUserName("**@126.com");
mailInfo.setPassword("******");
mailInfo.setFromAddress("**@126.com");
mailInfo.setToAddress("**@126.com");
解决方案 »
- 一天是24小时么?
- 关于擦出的补偿问题
- 把很多参数写成public static final形式可不可以?
- 如何把一个double型的数据转换成String
- InputStream/OutputStream和Reader/Writer在实现结果上是一样的吧?那么他们不一样的地方在哪啊?
- 小妹在线等待使用CVS工具?
- Container中的dispose()
- 求JAVA核心技术1,2卷,要最新版的,是最新版的(6版(不包括)以上的),100分给第一个有效的提供者,行动吧朋友们!
- 哪有jdk源代码下载?版本尽量高点,1.4以上最好!
- 如何从Oracle数据库中读出时间信息。
- 简单的socket程序,但是cpu却一直是100%
- 用jdk1.6,怎么让button变成透明
84行是哪一行,建议把代码贴出来要么,你改下smtp.126.com为pop.126.com
认证出现问题了.那个properties试下设置验证功能,还有Transport发送邮件时用SendMessage(),如果用的是静态方法Send(),那么这个方法已经包括了连接,发送,和关闭,那么你在外面重写这些代码,将使谁失败.所以请检查一下.
public boolean sendTextMail(MailSenderInfo mailInfo) {
MyAuthenticator authenticator = null;
Properties pro = mailInfo.getProperties();
if (mailInfo.isValidate()){
authenticator = new MyAuthenticator(mailInfo.getUserName(),mailInfo.getPassword());
}
Session sendMailSession = Session.getDefaultInstance(pro,authenticator);
try{
Message mailMessage = new MimeMessage(sendMailSession);
Address from = new InternetAddress(mailInfo.getFromAddress());
mailMessage.setFrom(from);
Address to = new InternetAddress(mailInfo.getToAddress());
mailMessage.setRecipient(Message.RecipientType.TO,to);
mailMessage.setSubject(mailInfo.getSubject());
mailMessage.setSentDate(new Date());
String mailContent = mailInfo.getContent();
mailMessage.setText(mailContent);
Transport.send(mailMessage);
return true;
}catch(Exception e)
{
e.printStackTrace();
}
return false;
}
}