# Send and receive email

Configure outbound and inbound email on your self-hosted dimmi with SMTP, Amazon SES, Postmark, Mailgun, SendGrid, Resend, or Cloudflare.

Until you configure a mail driver, dimmi prints emails to its logs instead of delivering them.

Setting up Amazon SES (which also requires an S3 bucket, SNS topic, and IAM user)? Follow the dedicated [SES guide](https://github.com/dimmihq/dimmi/blob/main/deploy/selfhost/references/aws-ses.md).

## Outbound email

dimmi uses two mailers: `system` sends login links, invites, and alerts; `customer` sends support replies and broadcasts (and falls back to `system` if left unset).

```bash
dimmictl set <<'EOF'
DIMMI_MAIL__FROM__NAME=Acme Support
DIMMI_MAIL__FROM__EMAIL=no-reply@mail.example.com
DIMMI_MAIL__MAILERS__SYSTEM__DRIVER=smtp
DIMMI_MAIL__MAILERS__SYSTEM__HOST=smtp.example.net
DIMMI_MAIL__MAILERS__SYSTEM__USERNAME=<smtp_username>
DIMMI_MAIL__MAILERS__SYSTEM__PASSWORD=<smtp_password>
EOF
```

Append driver options to `DIMMI_MAIL__MAILERS__SYSTEM__` or `DIMMI_MAIL__MAILERS__CUSTOMER__`:

| `DRIVER` | Required and optional keys |
| --- | --- |
| `smtp` | `HOST`, `PORT` (default `587`), `USERNAME`, `PASSWORD`, `TLS` (`true` for port `465`) |
| `ses` | `REGION` (default `us-east-1`), `ACCESS_KEY_ID`, `SECRET_ACCESS_KEY`, `CONFIGURATION_SET` |
| `postmark` | `TOKEN`, `MESSAGE_STREAM` (default `outbound`) |
| `mailgun` | `API_KEY`, `DOMAIN`, `ENDPOINT` (default `https://api.mailgun.net`; use `https://api.eu.mailgun.net` for EU) |
| `sendgrid` | `API_KEY` |
| `resend` | `API_KEY` |

Verify your sending domain at your mail provider, then diagnose any missing records with:

```bash
docker compose -f /opt/dimmi/compose.yaml exec web /dimmi email:doctor mail.example.com
```

## Bounces and spam complaints

dimmi reads the bounce and spam reports that mailbox providers mail back to your inbound domain. Each one stops mail to that address, and the lasting ones count toward the [bulk email pause](/channels/sending-domain/#when-bulk-email-pauses).

Amazon SES reports bounces and complaints as events of its own instead. To count them, give your customer mail a configuration set that publishes `Bounce` and `Complaint` events to an SNS topic, then name both:

```bash
dimmictl set <<'EOF'
DIMMI_CHANNELS__EMAIL__SENDING__SES__CONFIGURATION_SET=dimmi-customer
DIMMI_CHANNELS__EMAIL__SENDING__SES__EVENTS_TOPIC_ARN=arn:aws:sns:us-east-1:<account>:dimmi-events
EOF
```

Subscribe the topic to `https://<app_domain>/webhooks/ses/events` after saving those settings. dimmi confirms the subscription itself and refuses posts from any other topic. The [SES guide](https://github.com/dimmihq/dimmi/blob/main/deploy/selfhost/references/aws-ses.md) has the commands.

| SES event | Mail to the address | Counts toward the pause |
| --- | --- | --- |
| Permanent bounce | Stops for good | Yes, as a bounce |
| Transient bounce | Stops for 72 hours | No |
| Complaint | Stops for good | Yes, as a spam report |

A report that reaches dimmi both by mail and as an event counts once. On the other providers, dimmi counts the reports that arrive by mail.

## Inbound email

Dedicate one domain solely to dimmi inbound mail (such as `inbound.example.com`). Point its `MX` records at your mail provider, then configure the inbound domain and driver:

```bash
dimmictl set <<'EOF'
DIMMI_CHANNELS__EMAIL__INBOUND_DOMAIN=inbound.example.com
DIMMI_CHANNELS__EMAIL__INBOUND__DRIVERS=postmark
DIMMI_MAILBOX__DEFAULT=postmark
DIMMI_MAILBOX__SOURCES__POSTMARK__DRIVER=postmark
DIMMI_MAILBOX__SOURCES__POSTMARK__USERNAME=<webhook_username>
DIMMI_MAILBOX__SOURCES__POSTMARK__PASSWORD=<webhook_password>
EOF
```

For another provider, swap `postmark` / `POSTMARK` for its driver name and set its options below (`<app_domain>` is your dimmi hostname):

| Driver | Environment options | Provider setup |
| --- | --- | --- |
| `postmark` | `USERNAME`, `PASSWORD` (random values you choose) | Inbound stream with raw email enabled, webhook URL `https://<webhook_username>:<webhook_password>@<app_domain>/webhooks/postmark/inbound` |
| `mailgun` | `SIGNING_KEY` (HTTP webhook signing key) | Receiving route forwarding to `https://<app_domain>/webhooks/mailgun/inbound/mime` |
| `sendgrid` | `PUBLIC_KEY` (webhook verification key) | Inbound Parse posting signed raw MIME to `https://<app_domain>/webhooks/sendgrid/inbound` |
| `resend` | `WEBHOOK_SECRET`, `API_KEY` | Webhook for `email.received` pointing to `https://<app_domain>/webhooks/resend/inbound` |
| `cloudflare` | `SECRET` (random value you choose) | Cloudflare Worker with that secret + catch-all Email Routing rule. Print the Worker code with `/dimmi email:cloudflare-worker`. |

Check your inbound pipeline anytime by running `/dimmi email:inbound-doctor` inside the `web` container. Once ready, workspaces can [forward their support addresses](/channels/support-email/) to your inbound domain.

---

Index of all dimmi docs: https://trydimmi.com/llms.txt (full text: https://trydimmi.com/llms-full.txt)
