Home / Email for Cloudflare Workers

For Cloudflare Workers

Email for Cloudflare Workers

Cloudflare Email Routing catches mail for a domain and forwards it somewhere else - useful, but one-directional, and there's no mailbox to reply from. Mektup gives a Worker a real mailbox instead: send and receive on your own domain, reachable with the same fetch() the Workers runtime already gives you.

Forwarding isn't a mailbox

Email Routing is a genuinely useful Cloudflare feature for catching mail at a domain and forwarding it to an existing address - but it only moves mail in one direction, into an inbox you already have elsewhere. It can't send, and there's nothing to check, reply from, or grant a teammate (or an agent) access to on the domain itself. Mektup runs real mail infrastructure behind a plain REST API, so the same domain gets a real mailbox: inbound and outbound, IMAP/SMTP/webmail for a person, and a REST API or MCP server for a Worker or an AI agent.

Sending from a Worker

// worker.js
export default {
  async fetch(request, env) {
    const { to, subject, text } = await request.json();

    const res = await fetch("https://api.usemektup.com/v1/emails", {
      method: "POST",
      headers: {
        Authorization: `Bearer ${env.MEKTUP_API_KEY}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        from: "hello@yourdomain.com",
        to,
        subject,
        text,
      }),
    });

    return new Response(await res.text(), { status: res.status });
  },
};

Nothing here is Node-specific - the Workers runtime's built-in fetch() is the entire integration, so there's no bundle-size cost and no compatibility flag to enable.

Setting it up

1. Register your domain

Add the domain to Mektup and get back the exact MX, SPF, DKIM, and DMARC records.

2. Add the DNS records

If the domain's DNS is already on Cloudflare, this is a few entries in the same zone you're already managing. It only adds MX and TXT records - any Worker routes, A/CNAME records, or Email Routing rules on the domain are untouched.

3. Store the API key as a secret

Create a mailbox, generate an API key, then run wrangler secret put MEKTUP_API_KEY so the Worker reads it from env at runtime instead of hardcoding it.

4. Call the API

Use the snippet above from any Worker handler, Durable Object, or Queue consumer. Replies land in the same mailbox - readable in Mektup's webmail, over IMAP/SMTP in a normal mail client, or through the API from another Worker.

What it costs

Getting started is free - 1 domain, 3,000 emails a month with no daily cap, and 3GB of storage, no credit card. See the full pricing.

Get started free

FAQ

Common questions

Does Mektup work from Cloudflare Workers?

Yes. Mektup is a plain HTTPS REST API, and the Workers runtime's built-in fetch() talks to it exactly like any other JSON API - no Node-only SDK, no polyfills.

How is this different from Cloudflare Email Routing?

Email Routing only forwards inbound mail on a domain to an existing address - it can't send, and there's no mailbox to reply from. Mektup gives a full mailbox: send, receive, IMAP/SMTP, webmail, and the same REST API a Worker calls.

Can an AI agent deployed on Workers use Mektup's MCP server?

Yes. Mektup's MCP server is itself a remote Streamable HTTP server (mcp.usemektup.com), the same shape a Workers-hosted agent or MCP client already talks to - no separate stdio process required.

Ready when you are

A real mailbox behind your Worker, not just a forward

Get started free