javax.mail.AuthenticationFailedException: 535 5.7.3 Authentication unsuccessful

后端 未结 5 1167
野的像风
野的像风 2021-01-18 07:29

I am sending e email using an SMTP error . I am getting Authentication unsuccessful. The username and password are correct. Am I doing something wrong.

The error log

5条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-18 07:48

    It looks like the problem in how you do the session part...

    try doing this:

    private Properties emailPorperties;
    

    ... ...

        emailPorperties = new Properties();
        emailPorperties.put("mail.smtp.host", "your host");
        emailPorperties.put("mail.smtp.socketFactory.port", "your port");
        emailPorperties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
        emailPorperties.put("mail.smtp.auth", "true");
        emailPorperties.put("mail.smtp.port", "your port");
        emailPorperties.put("mail.smtp.ssl.enable", "true");
        emailSession = Session.getInstance(emailPorperties, new Authenticator() {
    
                @Override
                protected PasswordAuthentication getPasswordAuthentication() {
                    System.out.println("Authenticating");
                    return new PasswordAuthentication(USER_NAME, PASSWORD);
                }
    
            });
    

提交回复
热议问题