Skip to content
ThorMail

Adapter Overview

Adapters are the core of ThorMail’s flexibility. They act as bridges between ThorMail’s standardized interface and specific delivery providers.

An adapter is a JavaScript class that acts as a universal translator. It takes ThorMail’s generic message format and converts it into specific actions for any external system.

While most users start with email, the possibilities are infinite. An adapter can be as complex as a global delivery network or as trivial (and absurd) as blinking a smart bulb.

Standard Delivery

SMTP servers, SendGrid, Mailgun, AWS SES, Twilio (SMS), and Push services.

Business Logic

Post data to a CRM, trigger a Zapier automation, or update a database record.

The Unusual

Print a physical copy on a thermal printer, send a fax, or post to a Slack channel.

The Absurd

Blink a Philips Hue light for every 1,000 emails sent or log messages to a physical LED ticker.

Basically, if it has an API, a CLI, or a network connection, you can build a ThorMail adapter for it.

Your App → ThorMail API → Queue → Worker → Adapter → Provider
  1. Registration: When installed, ThorMail discovers the adapter via npm
  2. Configuration: Users provide credentials through the dashboard (form generated from adapter schema)
  3. Validation: The adapter validates credentials by testing the connection
  4. Sending: When processing a message, ThorMail calls the adapter’s sendMail() method
  5. Response Handling: The adapter returns success/failure info for retry logic

All adapters in ThorMail are installed via the dashboard using NPM. ThorMail acts as a package manager, allowing you to search for, install, and manage your delivery engines directly from the UI.

Terminal window
# Example from ThorMail dashboard
Adapters Install thormail-adapter-sendgrid

Popular adapters available on NPM:

  • thormail-adapter-smtp (Universal)
  • thormail-adapter-sendgrid
  • thormail-adapter-mailgun
  • thormail-adapter-aws-ses
  • thormail-adapter-twilio
  • thormail-adapter-onesignal
  • thormail-adapter-webhook

Every adapter implements this interface:

class MyAdapter {
// Defines the configuration form
static getConfigSchema() { }
// Provides adapter metadata
static getMetadata() { }
// Initializes with user config
constructor(config) { }
// Sends a message
async sendMail({ to, subject, body, data, idempotencyKey }) { }
// Validates configuration
async validateConfig() { }
// Processes webhooks
async webhook(event, headers) { }
// Health check
async healthCheck() { }
}

For enterprise or internal deployments, you can configure a private NPM registry (such as Verdaccio) to host your proprietary adapters.

Path: Settings / Global / NPM Registry

Benefits:

  • Keep proprietary adapters internal and secure.
  • Full control over versioning and availability.
  • Auto-discovery from your private registry alongside public packages.