Resend Plugin
Send emails via Resend API with automatic image handling
What is Resend Plugin
The @simplens/resend plugin enables email delivery through the Resend API. Resend is a modern email API built for developers, offering excellent deliverability and a simple integration experience.
How It Works
This plugin creates a Resend client and handles email delivery with advanced features:
- The plugin receives the notification payload
- Replaces any template variables in subject and HTML content
- Automatically extracts base64 images and converts them to CID attachments
- Sends the email via Resend API
Resend free tier allows 100 emails/day. Pro plans offer 5,000+ emails/day. Check Resend Pricing for details.
Installation & Configuration
- Open Dashboard → Plugins (
/plugins). - Install
@simplens/resendfrom the plugin catalog. - Add a provider instance, enter
RESEND_API_KEYandFROM_EMAIL, and configure rate limits (e.g.,maxTokens: 100,refillRate: 100,refillInterval: dayfor the free tier). - Assign the provider as the default for the
emailchannel in Channel Routing.
Credentials are encrypted at rest in MongoDB and hot-reloaded across all workers and processors via Redis Pub/Sub.
Required Credentials
| Key | Description |
|---|---|
RESEND_API_KEY | Your Resend API key (get one here) |
FROM_EMAIL | Verified sender email address (verify domain) |
Rate Limiting Options
| Key | Default | Description |
|---|---|---|
maxTokens | 100 | Max emails in bucket |
refillRate | 100 | Tokens refilled per interval |
refillInterval | day | Interval: second, minute, hour, or day |
Recommended Rate Limit Configurations
| Plan | Suggested Config |
|---|---|
| Free | maxTokens: 100, refillRate: 100, refillInterval: day |
| Pro | maxTokens: 5000, refillRate: 5000, refillInterval: day |
Resend API Key Setup
Create a Resend Account
Go to resend.com and sign up for a free account.
Get Your API Key
Navigate to API Keys and create a new API key.
Verify Your Domain
Go to Domains and add your sending domain. Follow the DNS verification steps.
Configure Your Plugin
Enter RESEND_API_KEY and FROM_EMAIL when adding the provider in Dashboard → Plugins (/plugins).
You must verify your domain in Resend before sending emails. Without verification, you can only send to your own email address.
Provider Credentials in Dashboard
Enter these values when creating the provider instance in Dashboard → Plugins (/plugins) (encrypted at rest in MongoDB):
RESEND_API_KEY=re_xxxxxxxxxxxxxxxxxxxxxxxxx
FROM_EMAIL=notifications@yourdomain.comNotification Payload
- You can easily get and configure this request payload from
Payload Studioin Admin Dashboard
{
"request_id": "uuid-v4",
"client_id": "uuid-v4",
"channel": ["email"],
"webhook_url": "https://your-app.com/webhooks/simplens",
"recipient": {
"user_id": "user-123",
"email": "recipient@example.com"
},
"content": {
"email": {
"subject": "Welcome {{name}}!",
"html": "<h1>Hello {{name}}</h1><p>Your order #{{order_id}} is confirmed.</p>"
}
},
"variables": {
"name": "John",
"order_id": "12345"
}
}Notification Schema
| Field | Type | Required | Description |
|---|---|---|---|
channel | 'email' | ✅ | Must be 'email' |
recipient.user_id | string | ✅ | User identifier |
recipient.email | string | ✅ | Valid email address |
content.subject | string | ✅ | Email subject line |
content.html | string | ✅ | HTML content (must contain at least one tag) |
variables | object | ❌ | Template variables for replacement |
Features
| Feature | Description |
|---|---|
| HTML Email Support | Send rich HTML emails |
| Template Variables | Supports {{key}}, ${key}, {key}, $key syntax |
| Auto Image Extraction | Converts base64 images to CID attachments automatically |
| Rate Limiting | Configurable token bucket with refill intervals |
| Smart Retry | Classifies errors as retryable or non-retryable |
| TypeScript Support | Full TypeScript definitions included |
Template Variable Syntax
The plugin supports multiple template variable formats:
| Format | Example |
|---|---|
| Handlebars | {{variable}} |
| ES6 Template | ${variable} |
| Simple Brace | {variable} |
| Shell/PHP | $variable |
Unmatched variables are left as-is in the output, allowing for safe partial replacements.
Base64 Image Handling
The plugin automatically detects base64-encoded images in your HTML content and converts them to CID (Content-ID) attachments. This improves email deliverability as many email clients block inline base64 images.
Before processing:
<img src="data:image/png;base64,iVBORw0KGgo..." alt="Logo">After processing:
<img src="cid:embedded-image-0-1234567890" alt="Logo">The base64 data is automatically attached to the email as a proper image attachment.
Docs