> For the complete documentation index, see [llms.txt](https://chris-lomeli.gitbook.io/tiny-engines/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chris-lomeli.gitbook.io/tiny-engines/sandbox/sendgrid-mailer-intro.md).

# the mailer service

Our first service is a basic blocking spring boot java rest service that receives a simple request to email some recipient.

![](https://835605371-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MirRN1Vsv3GcZ0OdXtu%2Fsync%2F6f908bbabcf7c9a45946cadd261f7f7cdf934d17.png?generation=1630898608076460\&alt=media)

The service should:

* [x] Accept a simple json payload
* [x] Validate the json format and the input data
* [x] Generate a SendGrid API http request object and sends the request to the SendGrid API
* [x] Receive a Response object back from SendGrid and passes it back&#x20;
* [x] Make sure that any exception or edge case is captured and the user always sees an appropriate Response

![](https://835605371-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MirRN1Vsv3GcZ0OdXtu%2Fsync%2Fe7e2d841057469ba7b9cbdc0a6bc447fca427ab0.png?generation=1630870458464159\&alt=media)

## Component Detail

**SendgridController (Controller)** 1. accepts the json request 2. passes it to the SendgridHandler 3. Receives a Response and displays it ot the user

**SendgridHandler (Handler)** 1. receives the json request from the controller 2. validates the json 3. passes it as a SendgridRequest object to the SendgridMailer 4. receives the Response from the Mailer and sends it back to the Controller

**SendgridMailer (Mailer)** 1. receives the SendgridRequest from the Handler 2. validates the data 3. reformats it to a SendGrid Request object 4. Sends the Request to the SendGrid API 5. receives the Response from the API and sends it back to the Handler
