# @norvento/persistent-mail

> Mail sender with disk persistency

Latest version **2.5.0** (published 2026-09-07) · ISC license · 0 weekly downloads

## Install

```sh
npm install @norvento/persistent-mail
pnpm add @norvento/persistent-mail
yarn add @norvento/persistent-mail
bun add @norvento/persistent-mail
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.5.0 |
| Published | 2026-09-07 |
| First published | 2020-07-30 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=16.0.0 |
| Dependencies | 7 |
| Unpacked size | 56.9 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | norvento.ds, jmouriz_norvento, dcastro_norvento, yadrio_norvento, sorozco_norvento |

## Links

- npm: https://www.npmjs.com/package/@norvento/persistent-mail
- Repository: https://bitbucket.org/norvento/persistent-mail
- Homepage: https://bitbucket.org/norvento/persistent-mail#readme
- Issues: https://bitbucket.org/norvento/persistent-mail/issues
- npm.io page: https://npm.io/package/@norvento/persistent-mail

## Dependencies (7)

- [axios](https://npm.io/package/axios.md) ^0.27.2
- [dayjs](https://npm.io/package/dayjs.md) ^1.10.7
- [nanoid](https://npm.io/package/nanoid.md) ^3.1.20
- [email-templates](https://npm.io/package/email-templates.md) ^8.0.8
- [@azure/msal-node](https://npm.io/package/@azure/msal-node.md) 2.15.0
- [@norvento/logger](https://npm.io/package/@norvento/logger.md) 2.1.1
- [@norvento/scheduler](https://npm.io/package/@norvento/scheduler.md) ^2.0.0

## Recent versions

- 2.5.0 (latest) — 2026-09-07
- 2.4.0 — 2025-03-11
- 2.3.0 — 2024-10-24
- 2.2.1 — 2024-06-05
- 2.2.0 — 2024-05-29
- 2.1.0 — 2023-12-20
- 2.0.2 — 2023-06-26
- 2.0.1 — 2023-06-20
- 2.0.0 — 2023-06-20
- 1.0.3 — 2022-09-16
- 1.0.2 — 2022-09-12
- 1.0.1 — 2022-09-12
- 1.0.0 — 2022-09-12
- 0.9.0 — 2021-10-25
- 0.8.0 — 2021-02-09
- … 8 more at https://npm.io/package/@norvento/persistent-mail/versions

## README

# Persistent Mail

Mail sender with disk persistency. It uses microsoft graph api to send the mails.

## Config

You have two options to configure the library:

### From environment variables:
The following environment variables must be declared:
```
AZURE_CLIENT_ID
AZURE_TENANT_ID
AZURE_CLIENT_SECRET
MAIL_USERNAME
MAIL_PASSWORD
MAIL_STORE_PATH
MAIL_CRON
```

### From config object
A config object with the following properties must be provided:

```
{
    azureClientId: string,
    azureTenantId: string,
    azureClientSecret: string
    username: string,
    password: string,
    storePath: string,
    cron: string
}
```

## Recipients

The `to`, `cc` and `bcc` fields accept a single address, a comma separated string, or an array of addresses:

```
const mail = new Mail("to@domain.com, to2@domain.com", "subject", "body", undefined, undefined, undefined, "cc@domain.com", ["bcc1@domain.com", "bcc2@domain.com"]);
```

The constructor signature is:

```
new Mail(to, subject, text?, html?, importance?, attachments?, cc?, bcc?)
```

## Example with config from environment vars
The vars where previously defined in a .env file located at the root level

```
const { Mail, PersistentMail } = require("@norvento/persistent-mail");

const mail = new Mail('to', 'subject', 'body');

async function sendMail() {
    await PersistentMail.init();
    PersistentMail.sendMail(mail);
}

sendMail();
```

##Example with config from config object

```
const { Mail, PersistentMail } = require("@norvento/persistent-mail");

const mail = new Mail('to', 'subject', 'body');

const myConfig = {
    azureClientId: "my azure client id,
    azureTenantId: "my azure tenant id",
    azureClientSecret: "my azure client secret",
    username: "username",
    password: "password",
    storePath: "/tmp/persisten-mail",
    cron: "*/1 * * * *"
}

async function sendMail() {
    await PersistentMail.init(myConfig);
    PersistentMail.sendMail(mail);
}

sendMail();

```

---
_Source: https://npm.io/package/@norvento/persistent-mail · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
