> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lettr.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Getting Started

> Send transactional emails through Lettr's SMTP relay server and migrate from another provider without changing your code.

Send transactional emails through Lettr's SMTP relay server. If your application already uses SMTP or you're migrating from another email provider, you can switch to Lettr without changing your code — just update your SMTP credentials.

Using an AI coding agent? Give it this prompt to get started:

```text wrap expandable theme={null}
Set up email sending through Lettr's SMTP server in this project.

Read this guide first: https://docs.lettr.com/quickstart/smtp/introduction.md

1. Find where this project configures SMTP or sends email today, and point it at Lettr. If it doesn't send email yet, add one small, working example.
2. Use host `smtp.lettr.com` with the port and encryption settings from the guide. The username is always `lettr`; the password is the Lettr API key.
3. Read the API key from an environment variable. Never hard-code it or commit it.
4. Send from an address on a domain that is verified in Lettr.
5. When you're done, summarize what you changed and tell me how to send a test email.
```

## Why Use SMTP?

SMTP is a good choice when:

* **Legacy applications** — Your application already uses SMTP and changing to an HTTP API would require significant refactoring
* **Framework built-ins** — Your framework has built-in mail functions that expect SMTP credentials (WordPress, Django, Rails, etc.)
* **Third-party integrations** — You're connecting a CMS, CRM, or other tool that only supports SMTP configuration
* **Gradual migration** — You're migrating from another email provider and want to minimize code changes

> [!NOTE]
>
> If you're building a new application or have flexibility in your stack, consider using the [HTTP API](https://docs.lettr.com/api-reference/emails/send-email.md) or one of our SDKs instead. The API offers better error handling, request tracking, and doesn't require maintaining a persistent connection.

## Prerequisites

Before you begin, make sure you have:

> [card] [API Key](https://app.lettr.com/api-keys)
>
> Create an API key in the Lettr dashboard

> [card] [Verified Domain](https://docs.lettr.com/learn/domains/sending-domains.md)
>
> Add and verify your sending domain

## SMTP Credentials

Use the following settings to connect to Lettr's SMTP server:

| Setting | Value |
| - | - |
| Host | `smtp.lettr.com` |
| Port | `465` (recommended), `2465`, `25`, `587`, `2587` |
| Username | `lettr` |
| Password | Your API key (starts with `lttr_`) |

> [!WARNING]
>
> Your SMTP password is your Lettr API key. Never commit this to version control or share it publicly. Store it in environment variables or a secrets manager.

> [!NOTE]
>
> The username is always the literal string `lettr` — the same for every account, not your email address. Your account is identified by the API key you send as the password.

## Sender Address

The address in your message's `From:` header must belong to a [verified sending domain](https://docs.lettr.com/learn/domains/sending-domains.md). Lettr validates that header address, not the SMTP envelope sender your client uses in `MAIL FROM`. Most libraries set both from the same value, but if you configure them separately, the `From:` header is the one that has to match.

If the address isn't on a verified domain, authentication still succeeds and the message is rejected afterwards, at the point your client sends the message body.

> [!TIP]
>
> To test your SMTP setup before your domain is verified, use a [sandbox API key](https://docs.lettr.com/learn/api-keys/sandbox.md) as the password. Sandbox keys work over SMTP exactly like they do with the API: the domain requirement is waived, and every message is redirected to your own inbox instead of the real recipients.

## Ports & Security

The port you choose determines the security protocol for your SMTP connection:

| Type | Ports | Security |
| - | - | - |
| SMTPS | `465`, `2465` | Implicit TLS — establishes a secure connection immediately |
| STARTTLS | `25`, `587`, `2587` | Explicit TLS — starts unencrypted, then upgrades to a secure connection |

We recommend **port 587** with STARTTLS, the most widely supported option. Use **port 465** if your client supports implicit TLS.

> [!TIP]
>
> If you're behind a restrictive firewall, port `2465` and `2587` are alternate ports that often work when standard ports are blocked.

## Quick Test with swaks

Verify your SMTP connection using `swaks` (Swiss Army Knife for SMTP):

```bash theme={null}
swaks --to recipient@example.com \
  --from sender@yourdomain.com \
  --server smtp.lettr.com:465 \
  --auth LOGIN \
  --auth-user lettr \
  --auth-password "lttr_your_api_key_here" \
  --tlsc \
  --header "Subject: Hello from Lettr" \
  --body "This is a test email sent via SMTP."
```

If the connection succeeds, you'll see output showing the SMTP conversation and a confirmation that the message was accepted.

> [!TIP]
>
> `swaks` is available via package managers: `brew install swaks` (macOS), `apt-get install swaks` (Ubuntu/Debian), or download from [jetmore.org/john/code/swaks](http://www.jetmore.org/john/code/swaks/).

## Open and Click Tracking

Open and click tracking are enabled by default. To disable both for a message, add these headers using your mail library:

```text theme={null}
X-Lettr-Track-Opens: false
X-Lettr-Track-Clicks: false
```

Each header is optional and controls its own setting. Use `true` to explicitly enable tracking, or omit the header to keep the default. See [SMTP tracking headers](https://docs.lettr.com/learn/sending/tracking.md#smtp-tracking-headers) for validation rules and examples.

## HTML and Text Encoding

Use UTF-8 for your HTML and plain text, and let your mail library generate the MIME message and its transfer encoding. Lettr supports quoted-printable and base64 content, including multipart messages with attachments. Do not manually encode content before passing it to a library that already handles transfer encoding.

Accented and other non-ASCII characters come through intact. If your application still sends HTML or text in an older charset, such as ISO-8859-2 or Windows-1250, Lettr converts it to UTF-8 based on the `charset` declared in the part's `Content-Type` header.

If Lettr can't decode the message body at all — for example, because of broken base64 or a malformed MIME structure — the message is rejected permanently with `554 5.6.0`, so your mail client doesn't keep retrying a message that will never go through.

## Embedded Images

Images embedded in the message and referenced from your HTML with a `cid:` URL, such as `<img src="cid:logo@example.com">`, display inline in the delivered email. Most mail libraries create these for you (for example, PHPMailer's `addEmbeddedImage()` or Laravel's `$message->embed()`). An image part is kept inline when it has a `Content-ID` and is marked `inline` or has no `Content-Disposition`; other files are delivered as regular attachments.

## BCC Is Not Private Over SMTP

> [!WARNING]
>
> Do not use BCC when sending over SMTP. Recipients you add with BCC are **visible to everyone else on the message**.
>
> BCC addresses are not carried in the message headers — your client passes them in the SMTP envelope, alongside the To and Cc addresses. Lettr's SMTP relay reads recipients from that envelope and cannot tell which ones were meant to be blind, so every address is delivered as a regular `To` recipient.

To keep recipients hidden from one another, send a separate message to each one. If you're sending the same content to many people, the [HTTP API](https://docs.lettr.com/api-reference/emails/send-email.md) handles BCC correctly and supports [batch sending](https://docs.lettr.com/learn/sending/batch-sending.md) with per-recipient personalization.

## Limits

| Limit | Value |
| - | - |
| Max recipients per message | 50 (combined to, cc, bcc) |
| Max message size (including attachments) | 50 MB |
| Failed authentication attempts | 5 per 5 minutes, then a 15-minute block |

> [!NOTE]
>
> The recipient limit matches the [HTTP API](https://docs.lettr.com/learn/sending/recipients.md). Exceeding it returns `452 Too many recipients`.

## Framework Integration Guides

Choose your framework or library for specific setup instructions:

> [card] [Laravel](https://docs.lettr.com/quickstart/smtp/laravel.md)
>
> Configure Laravel's mail system with SMTP

> [card] [PHPMailer](https://docs.lettr.com/quickstart/smtp/phpmailer.md)
>
> Send emails with PHPMailer

> [card] [Supabase](https://docs.lettr.com/quickstart/smtp/supabase.md)
>
> Send Supabase Auth emails through Lettr

## Troubleshooting

> [accordion] Authentication Failed
>
> If you see "Authentication failed" or "535 Authentication credentials invalid":
>
> * Verify your API key is correct and starts with `lttr_`
> * Check that the username is exactly `lettr` (lowercase) — not your email address
> * Ensure your API key hasn't been revoked in the [dashboard](https://app.lettr.com/api-keys)
> * If the key is restricted to specific IP addresses, confirm the machine you're sending from is on that list. This returns `535 Access denied. Your IP address is not allowed.`

> [accordion] Temporarily Blocked After Failed Attempts
>
> Five failed authentication attempts within five minutes will block your IP address for 15 minutes. While blocked, connections are refused with:
>
> ```
> 421 Too many authentication failures, try again later
> ```
>
> The block applies to your IP address across every port, so switching ports won't restore access — wait for it to expire. A successful login clears the counter, so fix the credential before retrying.

> [accordion] Connection Timeout
>
> If the connection times out:
>
> * Check your firewall isn't blocking outbound connections on the SMTP port
> * Try alternate ports (`2465` or `2587`)
> * Verify `smtp.lettr.com` resolves correctly: `nslookup smtp.lettr.com`
>
> Many cloud providers and residential ISPs block outbound port `25` by default. Use `465` instead.

> [accordion] Authentication Works but the Message Is Rejected
>
> If your client connects and logs in, then fails when sending the message body, the credentials are fine and the message itself was refused. Common causes:
>
> * The `From:` address isn't on a [verified sending domain](https://docs.lettr.com/learn/domains/sending-domains.md). Note that Lettr checks the `From:` header, not the envelope sender
> * The message exceeds 50 recipients (`452 Too many recipients`) or 50 MB
> * Your account has reached its [sending quota](https://docs.lettr.com/learn/sending/usage-quotas.md)
>
> An invalid or duplicate [tracking header](https://docs.lettr.com/learn/sending/tracking.md#smtp-tracking-headers) returns `554 5.6.0`. Correct the header before retrying.
>
> A message body that can't be decoded (for example, broken base64 or a malformed MIME structure) also returns `554 5.6.0`. This is permanent — fix how the message is built rather than retrying it.
>
> Other API forwarding errors return `451` with the reason from the API. Sends are recorded in the [dashboard](https://app.lettr.com) alongside API sends, so check there for the full error.

> [accordion] TLS/SSL Errors
>
> If you see TLS or SSL handshake errors:
>
> * Ensure you're using the correct encryption setting for your port (implicit TLS for 465, STARTTLS for 587)
> * Update your TLS/SSL libraries if you're using older versions
> * Some older SMTP clients may not support modern TLS versions — consider upgrading or using the HTTP API instead
> * For background on TLS between mail servers, see [Email in Transit: STARTTLS, MTA-STS, and TLS-RPT](https://docs.lettr.com/knowledge-base/fundamentals/email-transport-security.md)

## SMTP vs API

Here's a quick comparison to help you decide:

| Feature | SMTP | HTTP API |
| - | - | - |
| **Setup complexity** | Low — standard SMTP config | Medium — requires SDK or HTTP client |
| **Error handling** | Limited — SMTP status codes only | Rich — detailed JSON error responses |
| **Request tracking** | No request ID returned | Returns `request_id` for tracking |
| **Attachments** | Standard MIME encoding | Base64 in JSON payload |
| **Open and click tracking** | Per-message tracking headers | Per-message `options` object |
| **BCC** | Not private — BCC recipients are visible | Kept private |
| **Templates** | Not supported | Full template support |
| **Metadata** | Not supported | Custom metadata supported |
| **Webhooks** | Not supported | Full event tracking |
| **Performance** | Slower — persistent connection overhead | Faster — single HTTP request |

> [!NOTE]
>
> Both SMTP and the HTTP API deliver emails with the same reliability and deliverability. The choice depends on your application's needs and existing infrastructure.

## What's Next

> [card] [Laravel SMTP Setup](https://docs.lettr.com/quickstart/smtp/laravel.md)
>
> Configure Laravel to send via SMTP

> [card] [PHPMailer Setup](https://docs.lettr.com/quickstart/smtp/phpmailer.md)
>
> Use PHPMailer with Lettr SMTP

> [card] [Supabase Setup](https://docs.lettr.com/quickstart/smtp/supabase.md)
>
> Send Supabase Auth emails through Lettr

> [card] [API Reference](https://docs.lettr.com/api-reference/introduction.md)
>
> Explore the HTTP API alternative

> [card] [WordPress](https://docs.lettr.com/integrations/wordpress.md)
>
> Send WordPress emails through Lettr

> [card] [Integrations](https://docs.lettr.com/integrations/introduction.md)
>
> Stripe, Supabase, and more


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.