Quick setup examples
Hono
Send your first email from a Hono route using the sendping SDK.
Send your first email from a Hono app using the sendping SDK. The SDK uses the standard fetch API and works on Node.js, Bun, Cloudflare Workers, and other edge runtimes. Install it with npm install sendping, import SendPing, and call mb.emails.send().
Prerequisites
- A SendPing API key.
- A verified domain to send from.
1. Install the SDK
npm install sendping2. Add your API key
Store your key in the environment. On Node.js or Bun it is available as process.env.SENDPING_API_KEY; on Cloudflare Workers it comes from the request context bindings (c.env).
.env
SENDPING_API_KEY=mb_xxxxxxxxx3. Send email from a route
Create index.ts, instantiate the SDK client, and call mb.emails.send() inside a route handler.
index.ts
import { Hono } from 'hono';
import { SendPing } from 'sendping';
const app = new Hono();
const mb = new SendPing(process.env.SENDPING_API_KEY!);
app.get('/', async (c) => {
const { data, error } = await mb.emails.send({
from: 'Acme <onboarding@yourdomain.com>',
to: ['delivered@test.sendping.co'],
subject: 'hello world',
html: '<strong>it works!</strong>',
});
return c.json(error ? { error } : { data }, error ? 400 : 200);
});
export default app;A successful call returns the created email's
id. See the full request body in the Send an email reference.