---
title: Mail
icon: mail-single
description: Set up, configure, and run the Reloop mail microservice locally.
---
> For the complete documentation index, see [llms-docs.txt](/llms-docs.txt) or the site index [llms.txt](/llms.txt). Full docs corpus: [llms-full-docs.txt](/llms-full-docs.txt). Prefer markdown URLs (append `.md`) for agent consumption. Product skill: [skill.md](/skill.md).


Outbound transactional email API — send requests, template compilation, tracking, and SMTP handoff.

<Tip>
Run [`bun setup`](/docs/setup) once from the monorepo root. That starts Docker including [SMTP](/docs/setup/backend/smtp). Mailpit captures local outbound mail at [http://localhost:8025](http://localhost:8025).
</Tip>


## Overview

| Property | Value |
| :--- | :--- |
| **Directory** | `apps/backend/mail` |
| **Port** | `8015` |
| **Local URL** | [https://local.reloop.sh/api/mail](https://local.reloop.sh/api/mail) |
| **Swagger UI** | [https://local.reloop.sh/api/mail/openapi](https://local.reloop.sh/api/mail/openapi) |
| **Stack** | ElysiaJS · PostgreSQL · Redis · NATS · BullMQ |


## Quick start

```bash
bun be:mail:dev
```

Or `bun backend:dev` / `bun dev`.


## Environment

`apps/backend/mail/.env` — from `bun setup` / `bun env:setup`.

```bash
PG_URL=postgresql://reloop:reloop123@localhost:5432/reloop
REDIS_URL=redis://:reloop123@localhost:6379
PORT=8015
BASE_URL="https://local.reloop.sh"
NATS_URL=nats://localhost:4222
KUMOMTA_HTTP_URL=http://localhost:8020
TRACKING_SECRET=reloop_tracking_secret_default_123
NODE_ENV=development
```

| Variable | Required | Default |
| :--- | :--- | :--- |
| `PG_URL` | **YES** | `postgresql://...` |
| `REDIS_URL` | **YES** | `redis://...` |
| `PORT` | **YES** | `8015` |
| `KUMOMTA_HTTP_URL` | **YES** | `http://localhost:8020` |
| `TRACKING_SECRET` | No | Signs tracked link and open-pixel tokens |
| `NATS_URL` | **YES** | `nats://localhost:4222` |


## Commands

| Command | Description |
| :--- | :--- |
| `bun be:mail:dev` | Start dev server with hot reloading |
| `bun run --filter=be-mail build` | Compile production bundle |
| `bun run --filter=be-mail start` | Run compiled production build |
| `bun run --filter=be-mail check-types` | TypeScript type-check |


## Architecture

| Layer | Detail |
| :--- | :--- |
| **Send pipeline** | Validates API keys, compiles templates, injects tracking links |
| **Queues** | BullMQ workers dispatch via Redis (`mail-queue`, `mail-retry-queue`) |
| **MTA handoff** | Delivers to the [SMTP](/docs/setup/backend/smtp) engine on port `8020` |
| **Schema** | `email_log` in `packages/db/src/schema/email.ts` |


## Next

<CardGroup cols={2}>
  <Card icon="rocket" title="Setup" href="/setup">
    One-command local bootstrap
  </Card>
  <Card icon="smtp" title="SMTP" href="/setup/backend/smtp">
    Outbound KumoMTA edge
  </Card>
  <Card icon="layout" title="Template" href="/setup/backend/template">
    HTML compilation source
  </Card>
  <Card icon="link" title="Links" href="/setup/frontend/links">
    Click and open tracking
  </Card>
</CardGroup>
