看你使用的包是否支持SMTP密码验证...如果支持,就会提供方法set用户名和密码,否则就是不支持。

解决方案 »

  1.   

    class SmtpAuthenticator extends Authenticator {
        String userName;
        String userPassword;    public SmtpAuthenticator(String userName, String userPassword) {
            this.userName = userName;
            this.userPassword = userPassword;
        }    protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication
                    (userName, userPassword);
        }
    }Properties props = System.getProperties();
    props.put("mail.smtp.auth", "true");
                    SmtpAuthenticator sa = new SmtpAuthenticator("xxxxxx",
                            "123456");
                    session = Session.getDefaultInstance(props, sa);