# Hono

> Send your first email from a Hono route using the mailblastr SDK.

Send your first email from a Hono app using the `mailblastr` 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 mailblastr`, import `MailBlastr`, and call `mb.emails.send()`.

## Prerequisites

- A MailBlastr [API key](https://www.mailblastr.com/docs/api-keys/overview).
- A [verified domain](https://www.mailblastr.com/docs/domains/managing) to send from.

## 1. Install the SDK

```bash
npm install mailblastr
```

## 2. Add your API key

Store your key in the environment. On Node.js or Bun it is available as `process.env.MAILBLASTR_API_KEY`; on Cloudflare Workers it comes from the request context bindings (`c.env`).

**.env**

```ini
MAILBLASTR_API_KEY=mb_xxxxxxxxx
```

## 3. Send email from a route

Create `index.ts`, instantiate the SDK client, and call `mb.emails.send()` inside a route handler.

**index.ts**

```ts
import { Hono } from 'hono';
import { MailBlastr } from 'mailblastr';

const app = new Hono();
const mb = new MailBlastr(process.env.MAILBLASTR_API_KEY);

app.get('/', async (c) => {
  const { data, error } = await mb.emails.send({
    from: 'Acme <onboarding@yourdomain.com>',
    to: ['delivered@example.com'],
    subject: 'hello world',
    html: '<strong>it works!</strong>',
  });

  return c.json(error ? { error } : { data }, error ? 400 : 200);
});

export default app;
```

> **Note:** A successful call returns the created email's `id`. See the full request body in the [Send an email](https://www.mailblastr.com/docs/api/emails-send) reference.
