Skip to content

Centralised template repository that receives json objects, applies a template and sends an email.

Notifications You must be signed in to change notification settings

domgom/mail-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

##mail-service

Centralised template repository that receives a HTTP POST with json data, applies a template and emails it.

Usage

  1. Add a new handlebars template to /templates/ We will use test.hbs for the example.

  2. Add the needed credentials to the different environments in /config/

  3. Start the application selecting the port you want to listen.

node index.js 8000
  1. Send a HTTP POST request with the dynamic data of the template in json format and the destination address.
curl localhost:8000 \
--header "x-template: test.hbs" \
--header "x-to: [email protected]" \
-d '{"name" : "John Doe"}' 
  1. You will get back a 200 response with a success message or a 500 in case any configuration fails.
{ "response" : "mail sent" }
  1. The mail address receives the email with the selected template
Hello, my name is John Doe.

Presets

You can also define shorthands in the /presets/ folder for widely used configurations

{
  "template": "registrationEmail.hbs",
  "from": "[email protected]",
  "subject": "Please confirm your signup",
  "to": "[email protected]"
}

This presets file can be selected by sending the x-presets header. Additional headers like x-to or x-subject will override the preset configuration.

Templates

The templates use handlebars and they are compiled and cached on the application startup to optimise runtime performance.

Mail setup

The mails are sent using nodemailer library using a stmp pool. Environment files in /config/ define the transport and pool size.

Roadmap

-Improve testing coverage.

-Define load tests.

-Add authentication capabilities.

-Accept gzip requests.

About

Centralised template repository that receives json objects, applies a template and sends an email.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published