Solve error javax.mail.AuthenticationFailedException

后端 未结 15 1175
太阳男子
太阳男子 2020-11-29 05:45

I\'m not familiar with this function to send mail in java. I\'m getting an error while sending email to reset a password. Hope you can give me a solution.

Below is m

15条回答
  •  清歌不尽
    2020-11-29 06:19

    You should change the port to 587, I tested your code and it's working fine

    If error still happens, please change session variable to code below:

    Session session = Session.getInstance(props, new javax.mail.Authenticator() {
        protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication(userName, password);
        }
    });
    

提交回复
热议问题