日期:2014-05-20  浏览次数:20847 次

java编写的javamail出现javax.mail.AuthenticationFailedException: 异常
源代码:
public static void main(String[] args) throws Exception {
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.host", "smtp.sina.com");
Session session = Session.getInstance(props);
session.setDebug(true);

Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("keyon"));
message.setText("Hello, I am Keyon Sui!");
Transport transport = session.getTransport();
transport.connect("smtp.sina.com", 25, "slyfeng", "sly123");
transport.sendMessage(message, new Address[]{new InternetAddress("942671941@qq.com")});
transport.close();
}

结果出现错误:
Exception in thread "main" javax.mail.AuthenticationFailedException: 535 No SMTP server defined. Use real server address instead of 127.0.0.1 in your account.

at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:826)
at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:761)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:685)
at javax.mail.Service.connect(Service.java:295)
at com.niit.demo01.Demo01.main(Demo01.java:25)
DEBUG SMTP: AUTH LOGIN failed

郁闷死了!!!好几天了还没解决哪位大侠帮帮忙,谢谢啦!!
javamail

------解决方案--------------------
救星啊,我跟你一样的问题,杀毒软件禁用就好了!