America/New_York
Work
/
Start a Project
Available nowChat with me
Projects

Mailsender – Scalable SMTP Email Service with Template Engine

Mailsender – Scalable SMTP Email Service with Template Engine
Avatar
January 18, 2026

Delivery snapshot

Record date: January 18, 2026. Technology and screenshots describe the delivered version documented on this date. Any performance observations belong to the same point-in-time record. The linked live site may include later changes made by the client or other providers.
Mailsender is a production-grade transactional email service built on Node.js, Express, and Nodemailer. It replaces per-project email configurations across agency work with a centralized, scalable platform featuring connection pooling, template rendering, bulk sending, and a full React admin UI. The service supports multiple SMTP providers through a configurable transporter map, with pure being the default. Retry logic with exponential backoff handles transient network failures gracefully, while connection pooling maximizes throughput for high-volume sending. A React-based frontend (using Radix UI, Lucide icons, and Tailwind CSS) provides project management, recipient list handling, and real-time metrics. The emailService.js module maintains a Map of named transporters. Adding a new provider is a config change, not a code change. Each transporter is independently configurable with its own host, port, credentials, and pool settings. Nodemailer's built-in pool manages concurrent connections, max messages per connection, and rate limiting. The configuration (pool, maxConnections, maxMessages, rateDelta, rateLimit) is tunable per provider without code changes. Templates live in /templates as .hbs files with layout support (base.hbs), partials, and custom helpers (formatDate, uppercase, eq, json). Variable substitution works for both single sends and bulk batches. The POST /api/v1/email/send-bulk endpoint accepts an array of recipients, each with their own data payload. A configurable batchSize controls how many emails are dispatched per connection cycle, preventing SMTP throttling. Transient errors (ECONNREFUSED, ETIMEDOUT, ENOTFOUND) trigger up to three retry attempts with exponential backoff (2s → 4s → 8s). The sendEmailWithRetry() function wraps all sends and logs retry attempts to the metrics service. JWT-protected routes with jsonwebtoken and bcryptjs for password hashing. Session cookies store the JWT for browser-based access, while API keys handle programmatic requests. The metricsService.js tracks retry counts, delivery success/failure rates, and per-project volumes. Metrics are queryable via GET /api/v1/metrics for dashboard visualization. Setting DEV_MODE=true in development logs all emails to the console instead of sending them. This lets us test templates and flows without touching real inboxes.
  • Express v4 – HTTP server and routing
  • Nodemailer v6 – SMTP client with pooling
  • Handlebars – Template engine with layouts and partials
  • React – Admin UI frontend
  • Radix UI – Accessible component primitives
  • Tailwind CSS – Utility-first styling
  • Lucide React – Icon library
  • JWT + bcryptjs – Authentication
  • Multer – File uploads (recipient lists)
  • Sharp – Image processing for inline attachments
  • Helmet + CORS + rate-limit – Security middleware
SMTP provider reliability
Different providers have different limits and behaviors. Abstracted the transporter into a configurable map so we can switch providers or add fallbacks without rewriting the sending logic.
Bulk send performance
Sending hundreds of emails in a single request overwhelms SMTP connections. Implemented configurable batching to stay within provider rate limits while maximizing throughput.
Template flexibility
Different email types need different layouts. Built a Handlebars layout system with partials and custom helpers so each template inherits a consistent base while supporting unique content.
  • Centralized email infrastructure across 10+ client projects
  • Scalable throughput via connection pooling and batching
  • Reliable delivery with automatic retry on transient failures
  • Template consistency with a shared Handlebars foundation
  • Full observability via metrics and delivery logs