Skip to main content

Self-Hosted Email API for Developers

EmailEngine is a self-hosted email API that lets you add email functionality to any application. Access Gmail, Outlook, and any IMAP mailbox through a single REST API. Unlike per-mailbox services like Nylas, EmailEngine uses flat annual pricing - connect unlimited accounts for one predictable cost.

What Can You Do With EmailEngine?​

Send Emails​

Send emails through any email provider with a single API endpoint. EmailEngine handles SMTP connections, OAuth2 authentication, retries, and delivery tracking.

curl -X POST "https://emailengine.example.com/v1/account/user123/submit" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"to": [{ "address": "user@example.com" }],
"subject": "Hello from EmailEngine",
"html": "<p>Your message here</p>"
}'

Receive Emails in Real-Time​

Get instant webhook notifications when new emails arrive, no polling required.

{
"account": "user123",
"path": "INBOX",
"event": "messageNew",
"data": {
"id": "AAAAAQAACnA",
"uid": 1838,
"unseen": true,
"subject": "Re: Meeting tomorrow",
"from": { "name": "Ann Client", "address": "client@example.com" },
"messageId": "<abc123@mail.example.com>"
}
}

The full payload carries the envelope, the headers, the attachment list, and a reference for fetching the body.

Manage Email Accounts​

Register and manage multiple email accounts with automatic connection handling.

curl -X POST "https://emailengine.example.com/v1/account" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"account": "user123",
"name": "User 123",
"email": "user@gmail.com",
"oauth2": {
"provider": "AAABlf_0iLgAAAAQ",
"refreshToken": "1//0gExampleRefreshTokenFromGoogle",
"auth": { "user": "user@gmail.com" }
}
}'

provider is the ID of an OAuth2 application registered in EmailEngine, and refreshToken comes from that application's authorization flow. EmailEngine can also run the flow for you, in which case neither value is yours to supply.

Search and Organize​

Search messages, organize mailboxes, manage flags, and download attachments.

Connect AI Agents​

Expose the connected mailboxes to AI agents over the Model Context Protocol. Point an MCP client at /mcp, hand it a narrowed access token, and it can search, read, file, draft and send mail without ever holding a mailbox credential.

# Register EmailEngine as an MCP server in Claude Code
claude mcp add --transport http emailengine https://emailengine.example.com/mcp \
--header "Authorization: Bearer YOUR_ACCESS_TOKEN"

Why EmailEngine?​

One API for All Providers​

  • IMAP/SMTP - Works with any email provider
  • Gmail API - Native Gmail integration with Cloud Pub/Sub
  • Microsoft Graph API - Native Microsoft 365 and Outlook integration
  • Consistent interface across all provider types

Built for SaaS Applications​

  • Multi-account - Manage thousands of email accounts
  • OAuth2 support - Built-in OAuth2 for Gmail, Google Workspace, Microsoft 365
  • Webhooks - Real-time notifications for all email events
  • Queue management - Automatic retries and delivery tracking

Running It Yourself​

  • Self-hosted - The mail and the credentials stay on your infrastructure
  • Tunable - Worker counts, connection limits, and Redis sit under your control
  • Self-healing - Dropped connections are re-established with backoff and failed deliveries retried
  • Persistent - One IMAP connection per account stays open, so reads do not pay for a login on every request

Quick Start​

Four steps from an empty install to a message in your webhook endpoint:

  1. Install EmailEngine - Set up with Docker, npm, or on platforms like Render.com
  2. Add Your First Account - Register an email account via API
  3. Send an Email - Submit your first message
  4. Receive Webhooks - Get notified of new emails

Common Use Cases​

Email-Integrated SaaS​

Build email functionality into your SaaS application:

Email Automation​

Automate email workflows:

Customer Support​

Integrate email into your support system:

  • Manage multiple support email accounts
  • Track email conversations
  • Send templated responses
  • Explore mail merge →

Email Analytics​

Analyze email communications:

  • Track email delivery and opens
  • Generate AI-powered email summaries
  • Monitor email activity across accounts
  • See AI integration →

Architecture Overview​

EmailEngine works as a middleware between your application and email providers:

EmailEngine Architecture

How it works:

  1. Your Application - Makes REST API calls to EmailEngine and receives webhook notifications
  2. EmailEngine - Maintains persistent connections to email providers and manages data synchronization
  3. Redis - Stores email metadata, message queues, and account data for fast access
  4. Email Providers - Gmail, Outlook, Microsoft 365, and any IMAP/SMTP server

Data flows:

  • API requests: Your app calls EmailEngine REST API → EmailEngine connects to email providers or retrieves from Redis
  • Webhooks: Email providers send updates → EmailEngine processes → Your app receives webhook notifications
  • Data storage: EmailEngine keeps the message index, account data and job queues in Redis. Message content is read from the mailbox on demand; only queued outbound messages and pending webhook payloads pass through Redis, until they are delivered

API Reference​

The REST API is documented in four parts, plus the generated endpoint reference:

Get Help​

System Requirements​

Redis, and Node.js 20 or newer when running from source; the packaged builds carry their own runtime. Installation has the memory figures and what drives them.

License​

EmailEngine requires a license key for production use. Get a license:


Next Steps​

New to EmailEngine?

  1. Read the introduction to understand what EmailEngine can do
  2. Follow the quick start guide to get your first email working
  3. Set up OAuth2 for Gmail or Outlook

Ready to build?

Need inspiration?


Frequently Asked Questions​

What is EmailEngine?​

EmailEngine is a self-hosted email gateway that provides a unified REST API for accessing email accounts. It supports IMAP, SMTP, Gmail API, and Microsoft Graph API, letting you build email features into your application without dealing with protocol complexity.

How is EmailEngine different from Nylas?​

EmailEngine is self-hosted with flat annual pricing, while Nylas is a managed service charging per connected mailbox. EmailEngine gives you full data control, and the flat fee comes out ahead once the mailbox count passes a crossover that depends on both vendors' current prices. See detailed comparison →

What email providers does EmailEngine support?​

EmailEngine works with any email provider: Gmail, Google Workspace, Microsoft 365, Outlook.com, Yahoo, FastMail, and any IMAP/SMTP compatible email service.

Is EmailEngine free?​

EmailEngine offers a 14-day free trial with full functionality. Production use requires an annual license from postalsys.com/plans.

Can I use EmailEngine to send emails?​

Yes. EmailEngine supports sending emails via SMTP or native APIs (Gmail API, Microsoft Graph) with features like attachments, HTML content, templates, mail merge, and delivery tracking.

Can AI agents use EmailEngine?​

Yes. EmailEngine includes an MCP server, so any Model Context Protocol client - Claude Code, Cursor, a claude.ai connector, or your own agent - can work with the connected mailboxes through a curated tool set. Agents authenticate with narrowed EmailEngine access tokens, so you decide which account they reach and whether they may only read or also send.

Where is my email data stored?​

EmailEngine keeps the message index (UIDs, flags, folder structure), account configuration and job queues in Redis, on your infrastructure. Message content is read from the mailbox on demand and is not copied to third-party servers. A queued outbound message and a pending webhook payload sit in Redis until they are delivered; the security FAQ has the details.

See Also​