@@ -35,6 +35,8 @@ description: "Send your mail using unsend in NodeJS"
|
|||||||
Get the API key from the [Unsend dashboard](https://app.unsend.dev/api-keys) and initialize the SDK
|
Get the API key from the [Unsend dashboard](https://app.unsend.dev/api-keys) and initialize the SDK
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
import { Unsend } from "unsend";
|
||||||
|
|
||||||
const unsend = new Unsend({ apiKey: "us_12345" });
|
const unsend = new Unsend({ apiKey: "us_12345" });
|
||||||
```
|
```
|
||||||
|
|
||||||
|
48
packages/sdk/README.md
Normal file
48
packages/sdk/README.md
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
# Unsend SDK
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- [Unsend API key](https://app.unsend.dev/api-keys)
|
||||||
|
- [Verified domain](https://app.unsend.dev/domains)
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
### NPM
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install unsend
|
||||||
|
```
|
||||||
|
|
||||||
|
### Yarn
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn add unsend
|
||||||
|
```
|
||||||
|
|
||||||
|
### PNPM
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm add unsend
|
||||||
|
```
|
||||||
|
|
||||||
|
### Bun
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bun add unsend
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
import { Unsend } from "unsend";
|
||||||
|
|
||||||
|
const unsend = new Unsend({ apiKey: "us_12345" });
|
||||||
|
|
||||||
|
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",
|
||||||
|
});
|
||||||
|
```
|
@@ -27,7 +27,7 @@ export class Unsend {
|
|||||||
|
|
||||||
if (!this.key) {
|
if (!this.key) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Missing API key. Pass it to the constructor `new Unsend("re_123")`'
|
'Missing API key. Pass it to the constructor `new Unsend("us_123")`'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user