Push notifications without webhooks

Get instant notifications when emails arrive via Server-Sent Events (SSE). No public endpoint or inbound traffic required.

The Problem

  • You need real-time email notifications but can't expose a webhook endpoint
  • Browser apps and local dev environments can't receive incoming HTTP requests
  • Client-side apps (browser, mobile) have no way to receive webhooks
  • Firewalls block inbound traffic but allow outbound connections
  • Local development requires tunneling tools like ngrok to test webhooks

Why Existing Solutions Fall Short

Webhooks require exposing a public endpoint that accepts inbound requests

Polling the email API is slow, inefficient, and wastes resources

Setting up ngrok or tunnels for local development is tedious

Worker processes need complex queue infrastructure to coordinate

You shouldn't have to build this yourself.

How Mailhooks Solves This

Outbound Only

SSE uses outbound connections. No need to expose endpoints or configure firewalls.

Instant Delivery

Notifications arrive within milliseconds of email receipt. No polling delays.

Worker Distribution

Distributed mode load-balances notifications across workers automatically.

Works Everywhere

Browsers, long-running workers, local dev — anywhere that can maintain connections.

How It Works

1

Install SDK

Add the Mailhooks SDK to your project.

2

Subscribe to events

Call realtime.subscribe() with your handlers.

3

Receive notification

Your handler fires instantly when emails arrive.

4

Process email

Use the email metadata or fetch full content via API.

5

Auto-reconnect

SDK handles reconnection automatically on network issues.

Code Example

Subscribe to real-time push notifications with just a few lines of code.

Webhook Payload

{
  "type": "email.received",
  "timestamp": "2025-01-15T10:30:00.000Z",
  "data": {
    "id": "email_abc123",
    "from": "sender@example.com",
    "to": [
      "inbox@yourapp.mailhooks.dev"
    ],
    "subject": "New order #12345",
    "domain": "yourapp.mailhooks.dev",
    "hasAttachments": true,
    "attachmentCount": 1,
    "createdAt": "2025-01-15T10:30:00.000Z"
  }
}

Handler Code

import { Mailhooks } from '@mailhooks/sdk';

const mailhooks = new Mailhooks({ apiKey: 'mh_xxx' });

// Subscribe to push notifications
const subscription = mailhooks.realtime.subscribe({
  // Choose mode: 'broadcast' (all clients) or 'distributed' (load balance)
  mode: 'broadcast',

  onConnected: (payload) => {
    console.log('Connected!', payload.connectionId);
  },

  onEmailReceived: async (email) => {
    console.log(`New email from ${email.from}: ${email.subject}`);

    // Fetch full email content if needed
    const content = await mailhooks.emails.getContent(email.id);
    processEmail(content);
  },

  onError: (error) => {
    console.error('Connection error:', error);
  },

  autoReconnect: true, // Auto-reconnect on disconnect
});

// Later, disconnect when done
subscription.disconnect();

Get Started in 3 Steps

Takes ~2 minutes — no email infrastructure required.

1

Create a Mailhooks account

Sign up for free in seconds.

2

Create an inbox

Get a unique email address for your use case.

3

Add your webhook URL

Point to your endpoint and start receiving emails.

Get push notifications for emails in minutes