57 lines
1.1 KiB
Plaintext
57 lines
1.1 KiB
Plaintext
---
|
|
title: NodeJS
|
|
description: "Send your mail using unsend in NodeJS"
|
|
icon: node-js
|
|
---
|
|
|
|
## Prerequisites
|
|
|
|
- [Unsend API key](https://app.unsend.dev/api-keys)
|
|
- [Verified domain](https://app.unsend.dev/domains)
|
|
|
|
## Using SDK
|
|
|
|
<Steps>
|
|
<Step title="Install SDK">
|
|
<CodeGroup>
|
|
```bash npm
|
|
npm install unsend
|
|
```
|
|
|
|
```bash yarn
|
|
yarn add unsend
|
|
```
|
|
|
|
```bash pnpm
|
|
pnpm add unsend
|
|
```
|
|
|
|
```bash bun
|
|
bun add unsend
|
|
```
|
|
</CodeGroup>
|
|
|
|
</Step>
|
|
<Step title="Initialize SDK">
|
|
Get the API key from the [Unsend dashboard](https://app.unsend.dev/api-keys) and initialize the SDK
|
|
|
|
```javascript
|
|
import { Unsend } from "unsend";
|
|
|
|
const unsend = new Unsend({ apiKey: "us_12345" });
|
|
```
|
|
|
|
</Step>
|
|
<Step title="Send Email">
|
|
```javascript
|
|
unsend.emails.send({
|
|
to: "hello@acme.com",
|
|
from: "hello@company.com",
|
|
subject: "Unsend email",
|
|
html: "<p>Unsend is the best open source product to send emails</p>",
|
|
text: "Unsend is the best open source product to send emails",
|
|
});
|
|
```
|
|
</Step>
|
|
</Steps>
|