0

I turned on IMAP in gmail settings. I dont have two-factor auth, only with single password.

spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=${mymail}
spring.mail.password=${emailPassword}
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.connectiontimeout=5000
spring.mail.properties.mail.smtp.timeout=5000
spring.mail.properties.mail.smtp.writetimout=5000
    public void sendMessage(){
        SimpleMailMessage message = new SimpleMailMessage();
        message.setTo("mymail@gmail.com");
        message.setSubject("hello world");
        message.setText("Hello world \n Spring boot");
        emailSender.send(message);

    }


    @Override
    public void run(String... args) throws Exception {
        emailService.sendMessage();
    }

What I am doing wrong? exception: javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted.

andrew17
  • 851
  • 2
  • 10
  • 25
  • Try this : https://stackoverflow.com/questions/35347269/javax-mail-authenticationfailedexception-535-5-7-8-username-and-password-not-ac – amer Dec 20 '19 at 14:37
  • 1
    This issue is answered [here in stackoverflow](https://stackoverflow.com/questions/35347269/javax-mail-authenticationfailedexception-535-5-7-8-username-and-password-not-ac) – Seshidhar G Dec 20 '19 at 14:48

0 Answers0