# How it works

> From a send call to a delivered e-mail and the event that tells you so.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://mail.docs.sypnia.com/start/how-it-works/

For agents: How Mail works: POST https://mail.api.sypnia.com/v1/emails (key, verified sender domain, suppression check, limits → 202 with id) → render template to HTML + text, optional tracking, project queue respecting plan rate and warm-up → Amazon SES with your DKIM and return path → events (delivery, bounce, complaint) recorded, hard bounces/complaints suppressed, webhooks. SMTP relay smtp.mail.sypnia.com 587/465; templates/events/suppressions in Postgres; bodies kept for retention.

### 1. Your app sends

`POST https://mail.api.sypnia.com/v1/emails` with a template and its data, or a subject and a body. The API checks the key, that the sender's domain is verified, that recipients are not on the suppression list, and the project's limits, then answers `202` with the e-mail's id.

### 2. Mail renders and queues

The template is rendered with the data into HTML and plain text, tracking is added if you turned it on, and the message waits in the project's queue, which respects the rate your plan and warm-up allow.

### 3. Amazon SES delivers

The message is handed to Amazon SES, signed with your domain's DKIM key, with your domain's return path, and SES delivers it to the recipient's server.

### 4. Events come back

SES reports delivery, bounces and complaints; Mail records each as an event on the e-mail, adds hard bounces and complaints to the suppression list, and sends the events to your webhook.

## Where things live

| Thing                           | Where                                                                                |
| ------------------------------- | ------------------------------------------------------------------------------------ |
| The API                         | `https://mail.api.sypnia.com/v1` **\[Cloud]**                                        |
| The SMTP relay                  | `smtp.mail.sypnia.com`, ports 587 and 465 **\[Cloud]**                               |
| Templates, events, suppressions | the engine's Postgres                                                                |
| Message bodies                  | kept for the plan's retention, then deleted; events are kept longer without the body |
