> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Nodejs

# Node.js Quickstart

Send your first email with the Mailofly TypeScript SDK.

**Requires:** Node.js 18+ · [API key](/docs/getting-started/api-keys.md) · [Account key](sending-accounts.md)

***

## 1. Install

```bash theme={null}
npm install @mailofly/node
```

***

## 2. Send an email

```ts theme={null}
import { Mailofly } from "@mailofly/node";

const client = new Mailofly({
  apiKey: process.env.MAILOFLY_API_KEY!,
});

const { id } = await client.emails.send({
  from: "Acme <onboarding@example.com>",
  to: ["you@example.com"],
  subject: "Hello from Mailofly",
  html: "<p>It works!</p>",
  account_key: process.env.MAILOFLY_ACCOUNT_KEY,
});

console.log("Sent:", id);
```

***

## 3. Check mail logs

Open **[Emails](https://www.mailofly.com/user/emails)** or call:

```ts theme={null}
await client.mailLogs.list({ page: 1, page_size: 10 });
```

***

## Next.js App Router & CLI Automations

Use the Mailofly CLI to quickly scaffold an automated background API route in your Next.js project. This creates a type-safe automation handler compatible with Vercel and Mailofly's scheduling engine:

```bash theme={null}
npx @mailofly/cli generate nextjs-route my-email-handler
```

You can then import this handler and invoke it directly from your React Server Actions or as a REST endpoint to queue emails asynchronously without blocking the client.

***

## Next

* [TypeScript SDK](../sdks/typescript.md) — full reference
* [Sending examples](sending-examples.md)
* [API: Emails](https://docs.mailofly.com/api/emails)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.