---
title: "SMTP"
description: "Generic SMTP as a planned MainSDK email driver for any mail server - credentials, TLS, main.yaml, testing and swapping."
section: "integrations"
canonical: "https://mainsdk.dev/docs/integrations/smtp"
updated: "2026-10-28"
---

# SMTP

> Generic SMTP as a planned MainSDK email driver for any mail server - credentials, TLS, main.yaml, testing and swapping.

Canonical: https://mainsdk.dev/docs/integrations/smtp · Updated: 2026-10-28

SMTP is the standard protocol for handing mail to a mail server. It is named as an [`email`](https://mainsdk.dev/docs/interfaces/email) driver in the MainSDK requirements, so your app could send through any SMTP server: your company's relay, a self-hosted server, or a provider that offers SMTP access. Pick it when no API driver fits, or when policy requires mail to leave through your own relay.

## Interfaces it serves

### Email (`email`)

- Status: Building for 0.3 · ships as a stable API
- Driver: `smtp` (SMTP, planned driver)
- Docs: https://mainsdk.dev/docs/interfaces/email.md

```yaml
email:
  driver: smtp
```

Swap to another provider: `resend`, `ses`, `local`, `postmark`, `bird`.

## Before you start

1. Get the server's host, port and credentials for this app.
2. Use a server that supports TLS, and make sure your sending domain has SPF and DKIM set up for it.

Store the password in your secrets manager.

## Configure

```yaml title="main.yaml"
email:
  driver: smtp                 # planned driver, not in the spec yet
  key: secret:SMTP_PASSWORD    # suggested name; [TBD] host, port and username keys are not in the spec
```

A literal password fails to load with `MAIN-CONFIG-0004`.

## Use it

```ts title="app/account/welcome.ts"
import { email } from "mainsdk";

await email.send({ to: user.email, template: "welcome", data: {} });
```

## Local development and testing

`mainsdk dev` sends every email to the local inbox, so you don't need a mail server. `createTestApp()` from `@mainsdk/testing` runs `email` on its in-memory fake, and `chaos.on("email", { outage: true })` simulates an outage.

## What MainSDK adds on top

- Marketing email does not compile without an unsubscribe, with one-click unsubscribe headers.
- Unsubscribes, bounces and complaints suppressed for every later send.
- No tracking pixels or rewritten links by default; a retry never sends twice.

See [Email](https://mainsdk.dev/docs/interfaces/email).

## Limits and notes

- Planned driver, not in the spec yet; it comes through the driver kit later.
- SMTP has no standard way to report bounces and complaints back; how this driver feeds the suppression list is [TBD].
- Your server's host must be in the app's allowed network destinations.

## Swap to or from it

```yaml title="main.yaml"
email:
  driver: resend   # was smtp
```

Email is stateless, so the swap needs no migration.

## FAQ

**Can I use SMTP today?** Not through MainSDK yet. Use Resend or Amazon SES.

## Next

- [Email](https://mainsdk.dev/docs/interfaces/email)
- [Resend](https://mainsdk.dev/docs/integrations/resend), [Amazon SES](https://mainsdk.dev/docs/integrations/amazon-ses) and [Postmark](https://mainsdk.dev/docs/integrations/postmark)
