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");

解决方案 »

  1.   

    at bb.Test.main(Test.java:84) 
    84行是哪一行,建议把代码贴出来要么,你改下smtp.126.com为pop.126.com
      

  2.   

    class javax.mail.AuthenticationFailedException
    认证出现问题了.那个properties试下设置验证功能,还有Transport发送邮件时用SendMessage(),如果用的是静态方法Send(),那么这个方法已经包括了连接,发送,和关闭,那么你在外面重写这些代码,将使谁失败.所以请检查一下.
      

  3.   

    发送邮件如果用的是send方法的话,默认自动会帮你跟服务器进行相应的连接操作,如果使用这种方法就不要自己手动去连服务器,这样会连接两次服务器,也就是认证两次,肯定会出现发送不成功的问题的
      

  4.   

    public class SimpleMailSender {
    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;
    }
    }