I want to send an email to the user when he makes a reservation. To do this, I decided to try sending an email to two of my emails. I watched several tutorials and decided to do it as shown in the videos, but something didn't work out
I add this dependency in my pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<version>2.3.4.RELEASE</version>
</dependency>
And this in application.properties
I will swap my password with 'XXXXX' (this is the email password)
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=cinemawebkatrina@gmail.com
spring.mail.password=xxxxxxx
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
And this is my java code
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom("cinemawebkatrina@gmail.com");
message.setTo("ppikursov19@gmail.com");
message.setSubject("Test");
message.setText(strMessage);
emailSender.send(message);
Do you have any idea what I did wrong and why I can't send an email. I saw this error 'Username and Password not accepted'.
2021-04-04 15:45:57.737 ERROR 6532 --- [nio-8080-exec-6] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 support.google.com/mail/?p=BadCredentials f17sm1431874lfq.175 - gsmtp ] with root cause
In my application.properties file, do I need to use the email's username and password?