Quick setup examples

Bun

Send your first email from a Bun server using the sendping SDK.

Send your first email from a Bun app using the sendping SDK. Bun reads .env automatically and is fully compatible with the Node SDK. Install it with bun add sendping, then import SendPing and call mb.emails.send().

Prerequisites

1. Install the SDK

bun add sendping

2. Add your API key

Bun loads .env automatically and exposes it on process.env / Bun.env.

.env
SENDPING_API_KEY=mb_xxxxxxxxx

3. Send email from a Bun server

Create index.ts, instantiate the SDK client, and call mb.emails.send() from the request handler. Start it with bun index.ts.

index.ts
import { SendPing } from 'sendping';

const mb = new SendPing(Bun.env.SENDPING_API_KEY);

const server = Bun.serve({
  port: 3000,
  async fetch() {
    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 Response.json(error ? { error } : { data }, {
      status: error ? 500 : 200,
    });
  },
});

console.log(`Listening on http://localhost:${server.port} ...`);
A successful call returns the created email's id. See the full request body in the Send an email reference.