sendsend.email

Send email with Hono

A server-side call to the SendSend API from your Hono app.

  1. Create a test API key in the dashboard first: it never delivers real email. Switch to a live key once your domain is verified.
  2. On Cloudflare Workers, run: wrangler secret put SENDSEND_API_KEY. On Node or Bun, use an environment variable.
  3. Add this to src/index.ts:
import { Hono } from 'hono';

const app = new Hono<{ Bindings: { SENDSEND_API_KEY: string } }>();

app.post('/send', async (c) => {
  const { to } = await c.req.json();
  const res = await fetch('https://api.sendsend.email/v1/emails', {
    method: 'POST',
    headers: { Authorization: `Bearer ${c.env.SENDSEND_API_KEY}`, 'Content-Type': 'application/json', 'Idempotency-Key': crypto.randomUUID() },
    body: JSON.stringify({ from: 'Acme <hello@mail.acme.com>', to: [to], subject: 'Hello from Hono', html: '<p>It works!</p>' }),
  });
  return c.json(await res.json(), res.status as 200);
});

export default app;

Good to know