-
Notifications
You must be signed in to change notification settings - Fork 2
Create Notification Service
Piyush Chaudhari edited this page Mar 22, 2020
·
13 revisions
[Click me](```javascript function test() { alert("look ma’, no spaces"); }
Create spring boot **notification-service** project as microservice. <br>
Add below dependencies in your project.
`compile('org.springframework.boot:spring-boot-starter-freemarker')` for email templating <br>
`compile('org.springframework.boot:spring-boot-starter-mail')` for send mail via Gmail <br>
Set below property on [application.properties](https://github.com/PiyushChaudhari/spring-boot-micro-service/blob/master/src/main/java/notification-service/src/main/resources/application.properties)
`spring.mail.protocol=smtp` <br>
`spring.mail.host=smtp.gmail.com` <br>
`spring.mail.port=587` <br>
`spring.mail.username=set your gmail account id` <br>
`spring.mail.password=set your gmail password` <br>
`spring.mail.properties.mail.smtp.auth = true` <br>
`spring.mail.properties.mail.smtp.starttls.enable = true` <br>
`spring.mail.properties.mail.debug=true` <br>
**if authenticatin fails please go to https://myaccount.google.com/lesssecureapps and Allow less secure apps: ON** <br>
Create template [welcom-template.ftl](https://github.com/PiyushChaudhari/spring-boot-micro-service/blob/master/src/main/java/notification-service/src/main/resources/templates/welcom-template.ftl) under **resources/templates** directory <br>
Run spring boot **notification service**. It will be running on **8088** port. <br>
To send email notification you need user below information: <br>
**URL**: http://localhost:8088/notification/registration/welcome <br>
**Method**: POST <br>
**Content-Type**: application/json <br>
**Body**:
`{
"to":"[email protected]",
"name":"Piyu",
"signature":"Notification Team",
"location":"Ahmedabad"
}` <br>
```javascript
function test() {
alert("look ma’, no spaces");
}