- rename product to Scribase Mail across web app, emails, marketing and docs - new monochrome mark/favicons and neutral black/white theme; remove emoji UI - source code link (AGPL-3.0) in sidebar, login and unsubscribe pages - rewrite marketing site and self-hosting docs for OCI Email Delivery, add OCI notes page (event sources, unavailable features) - add NOTICE and MERGE.md crediting useSend and listing changes - add deploy/compose.scribase-mail.yml (web+postgres+redis, 1.47 GB limits), deploy/.env.example, Caddy site and DEPLOY.md for mail.scribase.com - replace legacy provider env vars in turbo.json, CI, env examples, docker files - OCI SDK packages as server externals for the standalone build Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
98 lines
2.2 KiB
Plaintext
98 lines
2.2 KiB
Plaintext
---
|
|
title: NodeJS
|
|
description: "Send your mail using Scribase Mail in NodeJS"
|
|
icon: node-js
|
|
---
|
|
|
|
## Prerequisites
|
|
|
|
- [Scribase Mail API key](https://mail.scribase.com/dev-settings/api-keys)
|
|
- [Verified domain](https://mail.scribase.com/domains)
|
|
|
|
## Using SDK
|
|
|
|
<Steps>
|
|
<Step title="Install SDK">
|
|
<CodeGroup>
|
|
```bash npm
|
|
npm install usesend-js
|
|
```
|
|
|
|
```bash yarn
|
|
yarn add usesend-js
|
|
```
|
|
|
|
```bash pnpm
|
|
pnpm add usesend-js
|
|
```
|
|
|
|
```bash bun
|
|
bun add usesend-js
|
|
```
|
|
</CodeGroup>
|
|
|
|
</Step>
|
|
<Step title="Initialize SDK">
|
|
Get the API key from the [Scribase Mail dashboard](https://mail.scribase.com/dev-settings/api-keys) and initialize the SDK
|
|
|
|
```javascript
|
|
import { UseSend } from "usesend-js";
|
|
|
|
const usesend = new UseSend("us_12345");
|
|
```
|
|
|
|
If you are running a self-hosted version of Scribase Mail, pass the base URL as the
|
|
second argument:
|
|
|
|
```javascript
|
|
const usesend = new UseSend("us_12345", "https://mail.scribase.com");
|
|
```
|
|
|
|
</Step>
|
|
<Step title="Send Email">
|
|
```javascript
|
|
usesend.emails.send({
|
|
to: "hello@acme.com",
|
|
from: "hello@company.com",
|
|
subject: "Scribase Mail email",
|
|
html: "<p>Scribase Mail is the best open source product to send emails</p>",
|
|
text: "Scribase Mail is the best open source product to send emails",
|
|
headers: {
|
|
"X-Campaign": "welcome",
|
|
},
|
|
});
|
|
```
|
|
|
|
> Custom headers are forwarded as-is. Scribase Mail only manages the `X-Scribase-Email-ID` and `References` headers.
|
|
</Step>
|
|
</Steps>
|
|
|
|
## Adding contacts programatically
|
|
|
|
<Steps>
|
|
<Step title="Get the contact book id">
|
|
Get the contact book id from the [Scribase Mail dashboard](https://mail.scribase.com/contacts/). Copy the contact book id
|
|
</Step>
|
|
<Step title="Add contacts">
|
|
|
|
```javascript
|
|
usesend.contacts
|
|
.create("clzeydgeygff", {
|
|
email: "hey@koushik.dev",
|
|
firstName: "Koushik",
|
|
lastName: "KM",
|
|
})
|
|
```
|
|
|
|
</Step>
|
|
|
|
<Step title="Update contact">
|
|
```javascript
|
|
usesend.contacts.update("clzeydgeygff", contactId, {
|
|
firstName: "Koushik",
|
|
lastName: "KM",
|
|
});
|
|
```
|
|
</Step>
|
|
</Steps>
|