Skip to content

Create Notification Service

Piyush Chaudhari edited this page Mar 22, 2020 · 13 revisions

Create spring boot notification-service project as microservice.
Add below dependencies in your project.

compile('org.springframework.boot:spring-boot-starter-freemarker') for email templating
compile('org.springframework.boot:spring-boot-starter-mail') for send mail via Gmail

Set below property on application.properties

spring.mail.protocol=smtp
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=set your gmail account id
spring.mail.password=set your gmail password
spring.mail.properties.mail.smtp.auth = true
spring.mail.properties.mail.smtp.starttls.enable = true
spring.mail.properties.mail.debug=true

if authenticatin fails please go to https://myaccount.google.com/lesssecureapps and Allow less secure apps: ON

Create template welcom-template.ftl under resources/templates directory

Run spring boot notification service. It will be running on 8088 port.
To send email notification you need user below information:

URL: http://localhost:8088/notification/registration/welcome
Method: POST
Content-Type: application/json
Body: { "to":"[email protected]", "name":"Piyu", "signature":"Notification Team", "location":"Ahmedabad" }

function test() {
 alert("look ma’, no spaces");
}