Skip to content
Snippets Groups Projects

Mail service

Features

This service allow to deliver mails to any email address from the address specified in the configuration. It also provides two particular endpoints, one for the user to give a feedback and another one for general contact purpose. Those endpoints will both send an email to the admin address specified in the configuration.

Dependencies

Endpoints

/contact: formulaire de contact

/feedback:

/send

/health This service will return a 200 http status code when all indicators are healthy. Otherwise it will return a 503 http status code. For this service we declared an health indicator that verify that the connection to the SMTP Server is available.

Implementation

How it works

mail-service

The entrypoint of the service is a REST API provided by a NestJS application. The service builds email bodies based on the information it receives and on the provided HTML templates. It then format a JSON with all the properties (to, from, body...) expected by an SMTP server to correctly send an email.

However the service does not send this JSON directly to the distant SMTP server. Indeed as a connection failure might occure, we chose to persist this object in a RabbitMQ queue. Then a small worker written in Node.js will consume the messages from the queue and send it to the SMTP server if correctly formatted. The messages will be removed (acknoledged) from the queue only if the SMTP received the message.

API documentation

NestJS provides a swagger module that can be easily integrated. Using specific annotations alongside your endpoints declaration, this module will automatically generates a swagger documentation, reachable at /api-doc.

Templates

AUTHZ

email-writer