NexoMailer SDK
AI-powered email infrastructure SDK
NexoMailer is a professional Node.js framework for developers who need more than just a simple mailer. It combines multi-provider failover, AI-driven personalization, and private analytics into a single, cohesive SDK.
⚡ Quick Start
1. Installation
Install the core framework and essential plugins via npm:
npm install @nexomailer/core @nexomailer/providers @nexomailer/analytics(You can also use pnpm add or yarn add)
2. Basic Configuration
import { NexoMailer } from '@nexomailer/core';
// Initialize the mailer with your basic setup
const mailer = new NexoMailer({
// Define at least one provider (SMTP, Resend, etc.)
providers: [{
type: 'smtp',
priority: 1,
config: {
host: 'smtp.gmail.com',
port: 587,
auth: { user: '...', pass: '...' }
}
}],
// Connect to your MongoDB for private analytics
analytics: {
mongodbUri: process.env.MONGODB_URI
}
});
await mailer.init();📦 Package Ecosystem
To keep the SDK lightweight, NexoMailer is split into specialized packages. You only install what you need.
| Package | Role | Why use it? |
|---|---|---|
@nexomailer/core | The Brain | Orchestrates failover, plugins, and module access. |
@nexomailer/providers | The Connectors | Native drivers for Resend, AWS SES, and SMTP. |
@nexomailer/analytics | The Memory | Handles MongoDB persistence and reporting. |
@nexomailer/ai | The Intelligence | Direct integration with LLMs for personalization. |
@nexomailer/templates | The Designer | Responsive MJML engine with Handlebars support. |
@nexomailer/queue | The Scheduler | BullMQ/Redis setup for background email processing. |
@nexomailer/tracking | The Tracker | Pixel and link tracking middleware. |
🔍 Under the Hood: The Nexo ID
When you call mailer.send(), NexoMailer does something unique:
- It generates a Unique UUID (The Nexo ID) before sending.
- It uses this ID for all tracking pixels and link rewrites.
- It returns this ID to you immediately.
Result: Even if you use 3 different providers for one campaign (because of failover), you can track everything via a single, consistent ID in your database.
🛠️ Best Practices
[!IMPORTANT] Environment Isolation: Always use the
environmenttag in your analytics config (stagingvsproduction) to keep your test data separate from real user metrics.