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
| Feature | REST API | SMTP |
|---|---|---|
| Template rendering | Yes — pass template ID and variables in the request | No — you must render the email before sending |
| Batch sending | Yes — send to multiple recipients in one request | No — one connection per message (or per SMTP session) |
| Immediate response with email ID | Yes | No — SMTP returns only a queue acknowledgment |
| Metadata and tags | Yes — include custom metadata in the JSON payload | Limited — use custom headers (X-Lettr-Metadata) |
| Scheduled sending | Yes — set scheduledAt in the request | No |
| Attachments | Yes — base64-encoded in JSON | Yes — native MIME attachments |
| Idempotency keys | Yes — via Idempotency-Key header | No |
| Works with legacy systems | Requires HTTP client support | Works with any SMTP-capable system |
| Connection overhead | New HTTPS connection per request (or connection pooling) | Persistent TCP connection with reuse |
| Firewall compatibility | Port 443 (HTTPS) — rarely blocked | Port 587 — sometimes blocked in hosted environments |
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.
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
| Setting | Value |
|---|---|
| Host | smtp.lettr.com |
| Port | 587 (STARTTLS) or 465 (TLS) |
| Authentication | Username: api, Password: your API key |
| Encryption | Required (TLS or STARTTLS) |
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
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
| Scenario | REST API | SMTP |
|---|---|---|
| Invalid recipient | Immediate 422 response with error details | 550 response during RCPT TO command |
| Rate limited | 429 response with Retry-After header | 421 response with retry guidance |
| Server error | 500 response | 451 temporary failure code |
| Authentication failure | 401 response | 535 authentication failed |
Migrating from SMTP to API
If you’re currently using SMTP and want to switch to the API for more features, follow these steps: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.
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.
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.
Update error handling
SMTP and API errors have different formats. Update your error handling to parse JSON responses and handle HTTP status codes.
Common Mistakes
Using SMTP in serverless environments
Using SMTP in serverless environments
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.
Not reusing SMTP connections
Not reusing SMTP connections
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.
Hardcoding SMTP credentials
Hardcoding SMTP credentials
Store SMTP credentials (your API key) in environment variables, not in your codebase. This applies equally to API keys used with the REST API.
Using SMTP when you need template rendering
Using SMTP when you need template rendering
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.
Related Topics
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