Node.js
The official Lettermint Node.js SDK sends email through a small, fully typed fluent API. You chain the parts of a message and call send(), and because the request and response types ship with the package, every field autocompletes in your editor. It runs anywhere Node runs: API routes, background workers, queue consumers, and serverless functions.
Every message is delivered through Lettermint's European infrastructure, which runs entirely inside the EU and processes mail in line with GDPR. That makes the SDK a solid choice for transactional email from a Node app, such as order confirmations, password resets, and account notifications.
Requirements
Before you start you need:
- Node.js 18 or newer
- A Lettermint account with a verified sending domain
- A Project API token from your project settings
If your domain is not verified yet, follow the domain setup guide first so your mail reaches the inbox instead of the spam folder.
1. Installation
Install the SDK via your preferred package manager:
2. Send your first email
Initialize the email client with your Project API token:
Code
Send your first email:
Code
3. Email Features
Basic Email
Send a simple text or HTML email:
Code
Multiple Recipients
Send to multiple recipients using CC and BCC:
Code
Custom Headers and Reply-To
Add custom headers and set reply-to addresses:
Code
Metadata
Add metadata for tracking and webhook payloads:
Code
Metadata is included in webhook payloads but not added to the actual email headers. Use it for tracking and analytics purposes.
Tags
Categorize emails for filtering and analytics:
Code
One tag per message. Tags can contain letters, numbers, hyphens, underscores, and spaces (max 255 characters). See Tags documentation for more details.
Route Selection
Direct emails to specific routes within your project:
Code
Idempotency
Pass an idempotency key so a retry never sends the same email twice. If a request with the same key is repeated within the idempotency window, Lettermint returns the original result instead of sending again:
Code
Derive the key from something stable in your domain, such as an order or invoice ID, so the same business event always maps to the same key. See the idempotency documentation for the full behaviour.
File Attachments
Attach files to your emails:
Code
4. Send an order confirmation
A real transactional send usually pulls several of these features together. This example sends a receipt with an HTML and plain-text body, tags it for analytics, attaches the order and customer IDs as metadata, and uses an idempotency key so a retry never emails the customer twice:
Code
The metadata you attach here travels with every webhook event for the message, so a later delivery or bounce maps straight back to the order in your database.
5. Response
Code
Track delivery, opens, and bounces
Sending is only half of a transactional setup. To see what happens after a message leaves your app, combine the SDK with Lettermint's platform features:
- Email tracking records opens and clicks, with bot filtering so your metrics stay accurate.
- Webhooks push delivery, bounce, and complaint events to your server in real time, so you can update order records or suppress bad addresses.
- Test addresses let you trigger a hard or soft bounce on demand while you build and verify your webhook handler.
Tracking is configured per route, so turn it on for the route your app sends through, then read the results from your dashboard or your webhook endpoint.
FAQ
Does the SDK support TypeScript?
Yes. The SDK is written in TypeScript and exports its request and response types, so every builder method and field is typed and autocompletes in your editor.
How do I stop the same email being sent twice?
Add an idempotency key with .idempotencyKey(), derived from a stable ID such as an order number. A repeated request with the same key returns the original result instead of sending again. See the idempotency documentation.
Is Lettermint email GDPR compliant and EU-hosted?
Yes. Lettermint runs exclusively on European infrastructure and processes email in line with GDPR, so transactional mail from your Node app is handled inside the EU.
How do I track opens, clicks, and bounces?
Enable tracking on your route and subscribe to webhooks to receive delivery, open, and bounce events. Use the test addresses to simulate bounces while you build your handler.
Next Steps
Tags
Organize and filter emails with tags.
Tracking
Track opens, clicks, and deliverability.
Webhooks
Receive real-time delivery notifications.
SMTP Alternative
Send via SMTP instead of the API.
GitHub Repository
Find the complete source code, report issues, or contribute on GitHub.