This is a simple spring application developed using Spring boot to demonstrate the integration of Spring Mail module for sending emails using html templates. This application is integrated with Gmail SMTP server that sends email(s), so in order to send emails using your Gmail account we need to change the Gmail account settings to provide permissions for other apps to be integrated. More details on how to change gmail account settings, click here: Enable Less secure apps
mvn clean install
Application consists of a POST API(/email) which accepts sender and receiver information in the request body which includes receiver email-id(s) for sending email(s). Dependencies to be added:
<!-- Spring mail boot starter -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<!-- Thymeleaf dependency for html templates -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
Additional auto configuration to be added to application.properties file
### Email configuration ###
spring.mail.username=<gmail-id>
spring.mail.password=<password>
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.protocol=smtp
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.ssl.trust=smtp.gmail.com
spring.mail.properties.mail.smtp.starttls.enable=true
Thanks much. Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.