你这个是身份认证没有通过,把:
Session session =Session.getDefaultInstance(props,null);
修改为:
Session session = Session.getDefaultInstance(properties, myauth); 
MyAuthenticator myauth = new MyAuthenticator("你的用户名", "你的密码");
另外添加一个类:
public class MyAuthenticator extends javax.mail.Authenticator {
private String strUser; private String strPwd; public MyAuthenticator(String user, String password) {
this.strUser = user;
this.strPwd = password;
} protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(strUser, strPwd);
}
}
就可以了。

解决方案 »

  1.   

    如果是从sohu发到163,那么应该登录sohu的邮箱啊,你的[smtpServer="smtp.163.com";]是怎么回事?
      

  2.   

    那个啊,这个测试程序我是从163发向163的
    刚才我查出问题了,主要是Prperties中的属性没设置好,谢谢各位大侠对我的帮助,谢谢各位
      

  3.   

    UP~~~~小店开张,大量视频培训录像,欢迎大家过去踩踩~~购买多多,优惠多多!助你踏上成功之路,拥有这些资料,您必将事半功倍,详细请登陆:http://shop34555988.taobao.com