Adding the spring-boot-starter-mail dependency in pom.xml. org.springframework.boot spring-boot-starter-mail
Step 2: Setting up Application.properties file with configurations required for using Gmail SMTP server. spring.mail.host=smtp.gmail.com spring.mail.port=587 spring.mail.username= spring.mail.password= spring.mail.properties.mail.smtp.auth=true spring.mail.properties.mail.smtp.starttls.enable=true
For password generation, 2-step verification needs to be enabled for your account Login to Gmail -> Manage your Google Account -> Security -> App Passwords -> Provide your login password -> Select app with a custom name -> Click on Generate