Mail - SirajChaudhary/comprehensive-example-on-microservices-using-spring-boot-with-spring-cloud GitHub Wiki
You can send an email using spring-boot-starter-mail module.
Step1: Add spring boot starter mail dependency in pom.xml in the microservice
<!-- spring boot starter mail -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
Step2: Add mail properties in application.yml in the microservice
spring:
# SEND MAIL PROPERTIES
mail:
host: smtp.gmail.com
port: '587'
username: YOUR_GMAIL_USERNAME
password: YOUR_GMAIL_PASSWORD
properties:
mail:
smtp:
auth: 'true'
connectiontimeout: '5000'
timeout: '5000'
writetimeout: '5000'
starttls:
enable: 'true'
Step3: Use Mail API to send an email