> For the complete documentation index, see [llms.txt](https://docs.mailofly.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mailofly.com/quickstarts/nodejs.md).

# Node.js

Send your first email with the Mailofly TypeScript SDK.

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

***

## 1. Install

```bash
npm install mailofly
```

***

## 2. Send an email

```ts
import { Mailofly } from "mailofly";

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
await client.mailLogs.list({ page: 1, page_size: 10 });
```

***

## Next

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.mailofly.com/quickstarts/nodejs.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
