javax.mail.AuthenticationFailedException: failed to connect, no password specified?

前端 未结 14 2031
广开言路
广开言路 2020-12-17 10:46

This program attempts to send e-mail but throws a run time exception:

javax.mail.AuthenticationFailedException: failed to connect, no password specified?
         


        
14条回答
  •  不知归路
    2020-12-17 11:02

    Your email session should be provided an authenticator instance as below

    Session session = Session.getDefaultInstance(props,
        new Authenticator() {
            protected PasswordAuthentication  getPasswordAuthentication() {
            return new PasswordAuthentication(
                        "myemail@gmail.com", "password");
                    }
        });
    

    a complete example is here http://bharatonjava.wordpress.com/2012/08/27/sending-email-using-java-mail-api/

提交回复
热议问题