Skip to main content
Lettr supports two methods for sending email: SMTP relay and the REST API. Both deliver the same result — your email reaches the recipient — but they differ in how your application connects to Lettr, the features available, and the performance characteristics. This guide helps you choose the right method and migrate between them.

How Each Method Works

REST API

Your application sends an HTTP POST request to Lettr’s API endpoint with the email content as a JSON payload. Lettr processes the request and returns a response immediately.

SMTP Relay

Your application connects to Lettr’s SMTP server and sends the email using the SMTP protocol. This works with any language, framework, or tool that supports SMTP — including legacy systems, WordPress, and command-line utilities.

Feature Comparison


When to Use the REST API

The API is the recommended method for most use cases. Choose it when:
  • You’re building a new integration. The API provides the richest feature set and the most straightforward developer experience.
  • You use Lettr templates. The API lets you pass a template ID and substitution variables — the rendering happens server-side.
  • You need batch sending. Send to multiple recipients in a single API call.
  • You want immediate feedback. The API response includes the email ID and any validation errors.
  • You’re in a serverless environment. Lambda, Cloud Functions, and similar platforms handle HTTP requests natively but may not support long-lived SMTP connections.
If you’re starting fresh and have no existing email infrastructure, use the API. It’s simpler to set up, easier to debug, and gives you access to all of Lettr’s features.

When to Use SMTP

SMTP is the right choice when:
  • You’re migrating from another provider. If your application already sends via SMTP, switching to Lettr requires only changing the SMTP host, port, and credentials — no code changes.
  • You use a platform that only supports SMTP. WordPress, legacy CMS systems, and many enterprise applications expose SMTP settings but not HTTP API configuration.
  • You’re sending from infrastructure tools. Monitoring systems, CI/CD pipelines, and cron jobs often use SMTP for notifications.
  • Your environment blocks outbound HTTPS but allows SMTP. Rare, but it happens in some corporate networks.

SMTP Connection Settings

Never use port 25 for sending through Lettr. Port 25 is unencrypted and is blocked by most cloud providers. Always use port 587 with STARTTLS or port 465 with implicit TLS.

Performance Considerations

Throughput

The REST API generally achieves higher throughput because:
  • JSON payloads are smaller than full MIME messages
  • Batch endpoints let you send multiple emails per request
  • HTTP/2 connection multiplexing reduces overhead
SMTP throughput can be improved by reusing connections (sending multiple messages per session), but it still involves more protocol overhead per message (EHLO, AUTH, MAIL FROM, RCPT TO, DATA, QUIT).

Latency

For a single email, the difference is negligible — both methods typically complete in under 200ms. For high-volume sending, the API’s batch endpoint reduces the number of round trips.

Error Handling

The API provides structured JSON errors that are easier to parse programmatically:
SMTP errors are text-based status codes that require parsing:

Migrating from SMTP to API

If you’re currently using SMTP and want to switch to the API for more features, follow these steps:
1

Audit your current SMTP usage

Identify all places in your codebase that send email via SMTP. Look for SMTP configuration (host, port, credentials) and mail-sending calls.
2

Replace with HTTP calls

Swap each SMTP send with an API call. If you use a framework like Laravel or Rails, update the mail driver configuration to use Lettr’s API transport instead of SMTP.
3

Adopt template rendering

If you’re currently building HTML emails in your application, consider moving them to Lettr templates. This lets you update email content without redeploying your application.
4

Update error handling

SMTP and API errors have different formats. Update your error handling to parse JSON responses and handle HTTP status codes.
5

Test in staging

Send test emails through the API to verify everything works before switching production traffic.

Common Mistakes

Serverless functions (AWS Lambda, Vercel Functions) have short execution timeouts and don’t maintain persistent connections. SMTP’s connection setup overhead makes it a poor fit. Use the REST API in serverless environments.
Opening a new SMTP connection for every email is wasteful. If you’re sending multiple emails in sequence, keep the connection open and send them in the same session. Most SMTP libraries support connection pooling.
Store SMTP credentials (your API key) in environment variables, not in your codebase. This applies equally to API keys used with the REST API.
SMTP sends pre-built MIME messages — Lettr can’t apply template rendering to them. If you want to use Lettr’s template engine with merge tags and conditional content, you need the REST API.

API Reference

Complete REST API documentation

Batch Sending

Send to multiple recipients in a single API call

Batch and Bulk Sending Best Practices

Best practices for high-volume email sending

Rate Limits

Understanding and handling rate limits

WordPress Integration

Send WordPress emails through Lettr

All Integrations

Stripe, Supabase, WordPress, and more