Quickstarts
Send with Hono
Send your first email from Hono.
Prerequisites
You need a running installation, a verified sending domain, and an API key with sending or full access. Set OPENSEND_API_KEY and OPENSEND_BASE_URL on the server. The base URL is your installation’s API origin (the public Convex HTTP origin), such as https://api.example.com, without an /api suffix.
Install
bash
pnpm add @opensendcc/sdk honoSend
typescript
import { Hono } from "hono";
import { Opensend } from "@opensendcc/sdk";
const opensend = new Opensend(process.env.OPENSEND_API_KEY!, {
baseUrl: process.env.OPENSEND_BASE_URL!, // https://api.example.com
});
const app = new Hono();
// Add your application authentication before this handler.
app.post("/send", async (c) => {
const { data, error } = await opensend.emails.send({
from: "Acme <hello@example.com>", to: "you@example.net",
subject: "Welcome", html: "<p>Welcome to Acme.</p>",
});
return c.json(error ?? data, error ? 502 : 200);
});
export default app;Try it
Run the server-side example or call your protected route. Open Emails in Opensend to inspect the message. An ID means the email entered the durable queue; it does not prove inbox delivery. Inspect delivery events and failures there.
Keep the key on the server. SES sandbox restrictions still apply. The HTTP equivalent is:
bash
curl "$OPENSEND_BASE_URL/emails" \
-H "Authorization: Bearer $OPENSEND_API_KEY" \
-H "Content-Type: application/json" \
-d '{"from":"Acme <hello@example.com>","to":["you@example.net"],"subject":"Hello from Opensend","html":"<p>Your first email is on its way.</p>"}'