For the complete site index, see llms.txt. Docs index: llms-docs.txt. Marketing corpus: llms-full.txt. Docs corpus: llms-full-docs.txt. Prefer markdown URLs where available (append .md).. Product skill: skill.md. Pricing: pricing.md. Docs MCP: /docs/mcp. Site MCP: /mcp.

Tutorials/

Send Email from Cloudflare Workers

5 MINUTES READ

Summary

Send transactional email from Cloudflare Workers using Reloop's HTTP API, with no Node.js SDK required. Works on the edge runtime.

Why the SDK doesn't work on Cloudflare Workers

Cloudflare Workers run in a V8 isolate, not a Node.js environment. Node.js built-ins like net, tls, and http are unavailable. The Reloop Node.js SDK uses these for SMTP, so on Workers, you call the HTTP REST API directly instead.

The good news: the HTTP API is simple

Everything the SDK does, the HTTP API does too. And fetch is available natively in Workers.

Setting up your Worker

src/index.ts
1export default {
2 async fetch(request: Request, env: Env): Promise<Response> {
3 if (request.method === "POST" && new URL(request.url).pathname === "/send") {
4 return sendEmail(env);
5 }
6 return new Response("Not found", { status: 404 });
7 },
8};

Sending an email via the HTTP API

typescript
1async function sendEmail(env: Env): Promise<Response> {
2 const response = await fetch("https://api.reloop.sh/v1/emails", {
3 method: "POST",
4 headers: {
5 Authorization: `Bearer ${env.RELOOP_API_KEY}`,
6 "Content-Type": "application/json",
7 },
8 body: JSON.stringify({
9 from: "hello@yourdomain.com",
10 to: "user@example.com",
11 subject: "Hello from the edge",
12 html: "<p>Sent from a Cloudflare Worker.</p>",
13 }),
14 });
15
16 const data = await response.json();
17 return Response.json(data);
18}

Storing your API key securely

Never hardcode the API key. Add it as a Cloudflare secret:

bash
wrangler secret put RELOOP_API_KEY

Access it as env.RELOOP_API_KEY in your Worker.

Defining the Env type

typescript
1interface Env {
2 RELOOP_API_KEY: string;
3}

Deploying

bash
wrangler deploy

Your Worker is now live globally on Cloudflare's edge network with email sending built in.

W: 320.0px180R20∠45.0°

Ship your first email with Reloop
in minutes.

Open-source, deliverability-focused, and yours to self-host or run on Reloop Cloud. No lock-in, no rewrite later.

Reloop